Skip to content

Page 1

SINTRAN SLIB

Programmers Guide

ND-860372.1 EN

ND
Norsk Data

[Photo: Color squares in a diagonal line]


Page 2

I'm sorry, but the text and elements on the scanned page are not visible.


Page 3

SINTRAN SLIB

Programmers Guide

ND-860372.1 EN


Page 4

Note

The numbering system for Norsk Data's documentation changed in September 1988. All numbers now start with an 8. The numbering structure is therefore ND-8xxxxxx.xx.xx. Example: ND-863018.3A EN. Existing manuals will receive a new number if and when they are updated or revised.

The information in this manual is subject to change without notice. Norsk Data A.S assumes no responsibility for any errors that may appear in this manual, or for the use or reliability of its software on equipment that is not furnished or supported by Norsk Data A.S.

Copyright © 1989 by Norsk Data A.S
Version 1
January 1989

Send all documentation requests to:

Norsk Data A.S
Graphic Centre
P.O. Box 25 - Bogerud
N-0621 Oslo 6
NORWAY


Page 5

Table of Contents

Chapter 1. INTRODUCTION

1.1. Synopsis ............................................................ 1
1.2. What is ARPANET ........................................ 3
1.3. Introduction to ND Socket Library ............. 5
1.4. Requirements ................................................... 6

Chapter 2. BASIC TERMS AND DEFINITIONS

2.1. Synopsis ............................................................ 9
2.2. Socket ............................................................... 11
2.3. Communication Domain .............................. 11
2.4. Socket Address .............................................. 12
2.5. Socket ID ......................................................... 12

Chapter 3. INTRODUCTION TO SLIB

3.1. Initialization ..................................................... 13
3.2. Socket Creation, Naming and Service Establishment .................. 15
3.3. Accepting Connections ................................... 18
3.4. Making Connections ....................................... 18
3.5. Sending and Receiving Data ............................ 19
3.6. Shutdown and Closing ..................................... 20
3.7. Sleeping ........................................................... 21
3.8. Datagram Sockets ............................................ 21

Chapter 4. ADVANCED TOPICS

4.1. Initializing Socket Library .............................. 25
4.1.1. WorkAreaP Parameter .................................. 27
4.1.2. initParam Parameter ...................................... 28
4.1.3. Other Parameters .......................................... 31
4.2. Multitasking in SLIB .......................................... 31
4.2.1. General Information ...................................... 31
4.2.2. How to Create Tasks ....................................... 32
4.2.3. Associating Data with the Tasks ................... 35
4.3. Event System ...................................................... 41
4.3.1. General Information ...................................... 41
4.3.2. Setting an Event to a Socket ......................... 42
4.3.3. External Events ............................................. 42
4.3.4. Own Events ..................................................... 43
4.4. Internet Address Binding ............................... 48
4.5. SLIoccl Routine .................................................. 55
4.5.1. Nonblocking Option ....................................... 56
4.5.2. No Activity Timer ............................................ 57
4.5.3. Set an Event Bit on a Socket ........................ 60
4.5.4. Network Status ............................................... 60


Page 6

Chapter 5. NETWORK ADMINISTRATION FILES

5.1. Introduction

  • Page 87

5.2. AIP-HOSTS:SYMB - Host Name Database

  • Page 87

5.3. AIP-NETWORKS:SYMB - Network Name Database

  • Page 89

5.4. AIP-PROTOCOLS:SYMB - Protocol Name Database

  • Page 90

5.5. AIP-SERVICES:SYMB - Service Name Database

  • Page 91

Chapter 6. EXAMPLES

6.1. Synopsis

  • Page 95

6.2. Server Example

  • Page 96

6.3. Client Example

  • Page 108

Chapter 7. PLANC INTERFACE

7.1. Introduction

  • Page 119

7.2. SLaccept - Accept a Connection on a Socket

  • Page 120

7.3. SLbind - Bind a Name to a Socket

  • Page 122

7.4. SLclose - Close a Socket Connection

  • Page 124

7.5. SLconnect - Initiate a Connection on a Socket

  • Page 125

7.6. SLexit - Terminate Current Task

  • Page 127

7.7. SLfork - Create a new Task

  • Page 128

7.8. SLgetOption - Get Socket Options

  • Page 129

7.9. SLgetpeernamе - Get Name of Connected Peer

  • Page 132

7.10. SLgetsockname - Get Socket Name

  • Page 133

7.11. SLinit - Initialization of the Socket Library

  • Page 134

7.12. SLioctl - I/O Control Request

  • Page 137

7.13. SLlisten - Listen for Connections on a Socket

  • Page 139

7.14. SLotherevent

  • Page 141

7.15. SLrecv - Receive a Message From a Socket

  • Page 142

7.16. SLrecvFrom - Receive a Message from a Socket

  • Page 144

7.17. SLsend - Send a Message from a Socket to Another

  • Page 146

7.18. SLsendTo - Send from a Socket to a Specific Address

  • Page 148

7.19. SLsense - Check Input Queue

  • Page 150

7.20. SLsetOption - Set Socket Options

  • Page 151

7.21. SLsetOwnEvents - Set SLIB Own Event Mask

  • Page 153

7.22. SLshutdown - Shut Down Part of Connection

  • Page 154

7.23. SLsleep - Sleep for a Specified Time on Specified Events

  • Page 156

7.24. SLsocket - Create an Endpoint for Communication

  • Page 158

Page 7

Chapter 8. NETWORK SUPPORT ROUTINES

  • 8.1. Introduction ................................................................................................................ 161
  • 8.2. Accessing Host Name Entry ................................................................................... 163
  • 8.3. Accessing Network Entry ......................................................................................... 164
  • 8.4. Accessing Protocol Entry ......................................................................................... 166
  • 8.5. Accessing Service Entry ........................................................................................... 167
  • 8.6. SLhtonl, SLhtons, SLntohl, SLntohs ..................................................................... 170

Chapter 9. IP ADDRESS MANIPULATION ROUTINES

  • 9.1. Internet "." Notation ................................................................................................. 171
  • 9.2. SLinNetAddr - Convert Internet '.' Notation to Binary Format ......................... 173

Chapter 10. TROUBLE SHOOTING

  • 10.1. How to Check a TCP Connection .............................................................................. 175
    • 10.1.1. How to Check Local TCP Controller/Network Connection ........................... 177
  • 10.1.2. In-depth Debugging of Error Situations ............................................................ 179
    • 10.1.2.1. How to Install the Internal TCP/IP Trace Tool ........................................... 180
    • 10.1.2.2. Internal Tracing in TCP/IP ........................................................................... 180
  • 10.1.3. Inspecting TCP/IP Status ..................................................................................... 182
  • 10.2. Some TCP/IP Monitor Commands .......................................................................... 188

Appendix A. THE :IMPORT AND :DEFS FILES

............................................................................................................................... 209

Appendix B. ERROR MESSAGES

............................................................................................................................... 227



Page 8

I'm sorry, the document appears to be blank. If you have another image or document, please provide it for conversion to Markdown.


Page 9

Preface

The product

SINTRAN Socket Library
ND 211566A00

This manual documents the PLANC interface of the SINTRAN Socket Library (SLIB). The library is based on the 4.2 BSD release of UNIX (Socket Library or SLIB). In this manual we refer to the library using the acronym SLIB.

The reader

This manual is written for the programmer who needs access to TCP/IP using the SLIB library.

Required knowledge

The reader should have a general understanding of data communication, knowledge of the SINTRAN III operating system, and programming experience in PLANC.

The following manuals supply additional information about products closely related to the SLIB product.

Manual Number
SINTRAN III Timesharing/Batch Guide ND-860132
NDIX Programmer Guide, Volume 2C ND-860247
COSMOS Programmer Guide ND-860164

Socket Library for PCS/1
ND 230072

To provide software developers with a standard interface for writing applications against TCP/IP and UDP, Norsk Data also offers Socket Library for MS-DOS environments. Socket Library for PCS/1 (Personal Communications System/1), may be ordered from Norsk Data A.S.


Page 10

The image provided does not contain any visible text or diagrams. If there is additional material or another page, please provide that for analysis.


Page 11

Chapter 1.

INTRODUCTION


Page 12

I'm sorry, but the page is blank.


Page 13

1.1. Synopsis

This chapter gives a brief introduction to ARPANET and to the Norsk Data Socket Library.

1.2. What is ARPANET

ARPANET (Advanced Research Projects Agency NETwork) is a network used by the American defence organizations throughout the American continent. Today ARPANET connects several defence institutions all over America.

A public version of ARPANET is used by universities and research institutions, in the USA as well as in Europe.

The architecture is used in both Local Area Networks (LANs) and in Wide Area Networks (WANs). The ARPANET model, and the protocols used, were defined before the ISO model became a standard. It has, therefore, been used as a de facto standard in local area networks.

Because ARPANET has been used as a de facto standard, ND has developed its own version for communication using ARPANET architecture and protocols. This will allow ARPANET compatibility over Ethernet as the common network.

ARPANET defines the standard Internet protocols listed on the following page.


Page 14

Introduction

  • IP (Internet Protocol)
    (The network-related protocol)
  • ICMP (Internet Control Message Protocol)
    (A protocol implemented in IP.)
  • TCP (Transmission Control Protocol)
    (A connection-oriented protocol)
  • UDP (User Datagram Protocol)
    (Which is the same logical level as TCP)

ND's implementation of the TCP/IP - Ethernet set of data communication protocols is based on Berkley's 4.2 BSD UNIX standard.


Page 15

1.3. Introduction to ND Socket Library

ND Socket Library is a programming interface (PLANC) consisting of a set of procedures that enable server and client processes to communicate with "TCP/IP" or "UDP/IP". The implementation resembles the Socket Library implementation running under the 4.2 BSD release of UNIX.

Further on in this manual, we will refer to the Socket Library as SLIB.

To illustrate how Socket Library may be viewed in layered architecture:

   +-------------+
   | Application |
   +-------------+
   |    SLIB     |
   +-------------+
   |  TCP / UDP  |
   +-------------+
   |     IP      |
   +-------------+
         |
   +-------------+
   |  [illegible] |
   +-------------+

Page 16

1.4. Requirements

To run an application using Socket Library, your ND system must meet the following requirements:

Hardware prerequisite

  • Ethernet II or Ethernet III controller(s).
  • Ethernet or Cheapernet cabling.

Software prerequisite

  • COSMOS TCP/IP Gateway version C (ND-211185) (for Ethernet II).

    or

  • TCP/IP Basic Module/III (ND-211327) (for Ethernet III).

You may install several Ethernet controllers of the same type in one host computer.

  • The files SLIB:DEFS and SLIB:IMPT must be included in your source code when you compile the application.
  • The following files must be available when you link your application:

    For an ND-100 application,

    1Bank program:

    • SLIB-1B-A00:BRF
    • NK-100-1BANK:BRF
    • PLANC-UTILLIB-1B:BRF
    • MON-CALL-1BANK:BRF
    • PLANC-1BANK:BRF

Page 17

2Bank Program

  • SLIB-2B-A00:BRF
  • NK-100-2BANK:BRF
  • PLANC-UTILLIB-2B:BRF
  • MON-CALL-2BANK:BRF
  • PLANC-2BANK:BRF

For an ND-500 or ND-5000 application:

  • SLIB-500-A00:BRF
  • NK-5000:NRF
  • PLANC-UTILLIB:NRF
  • MON-CALL-LIB:NRF
  • PLANC-LIB:NRF

Page 18

I'm sorry, I cannot convert the content of the page as it appears to be blank. If there is any specific content you would like to include, please provide a different image or a text description.


Page 19

Chapter 2

BASIC TERMS AND DEFINITIONS


Page 20

I'm sorry, I am unable to transcribe the content from this page. It appears to be blank except for headers and a footer.


Page 21

2.1. Synopsis

This chapter gives an introduction to basic terms and definitions used in SLIB.

2.2. Socket

Socket
A socket is one endpoint of a two-way communication path. SLIB applications are usually based on the client-server model. In this case, the server listens to a socket, and the client communicates to the server over another socket, which is the other endpoint of the communication path.

4.2 BSD UNIX implements three types of sockets:

  • Stream socket (or virtual circuit)
  • Datagram socket
  • Raw socket

Stream socket
A stream socket provides for bidirectional, reliable, sequenced, and non-duplicated flow of data without record boundaries.

Datagram socket
A Datagram socket supports bidirectional flow of data which is not promised to be sequenced, reliable, or non-duplicated.

Raw socket
Used to access internal network interfaces. This socket type is not discussed further in this manual.

2.3. Communication Domain

Communication domain
Sockets exist within communication domains. A communication domain is an abstraction introduced to bundle common properties of processes communicating through sockets.


Page 22

Internet Domain

This version of SLIB supports only Internet domain.

An Internet domain communicates by application across a network using the DARPA communication protocols.

2.4. Socket Address

Socket address
The socket address structure varies depending on the protocol being used and the communication domain.

Address structure
For Internet protocols, the socket address structure is shown in the table below:

address family 2 bytes (Internet family)
port number 2 bytes
Internet address 4 bytes (In network data order)

Table no. 1. Socket Address Structure

2.5. Socket ID

Socket ID
The socket ID has the same function as a file descriptor. It is a number, existing inside the program using SLIB, used to identify a socket. Zero is not used as a socket ID value.


Page 23

Chapter 3. INTRODUCTION TO SLIB


Page 24

I'm sorry, but I can't process what is shown on the page.


Page 25

3.1. Initialization

SLinit

The SLinit routine must be called before any other call to the Socket Library. Its purpose is to define a work area in the caller's data space for internal data structures used by the Socket Library. It also makes contact with protocol servers, and initializes SLIB.

SLinit(workArea, initParam, task, taskStackSize, taskDataP) =: status

For more details on how to initialize SLIB, see section 4.1.

3.2. Socket Creation, Naming and Service Establishment

Socket creation

Before a socket can be used, a socket descriptor for that socket must be allocated. When an application requests a socket with the SLsocket call, an endpoint for communication is created and a socket descriptor is returned to the requesting application.

Sockets may be connected or unconnected. An unconnected socket descriptor is obtained by SLsocket.

INTEGER : Domain, Type, Protocol
SLSockId : NewSocket

AF_INET =: Domain       % communication domain
SOCK_STREAM =: Type     % socket type
IN_PRO_TCP =: Protocol  % Protocol to be used

SLsocket(domain, type, protocol, NewSocket)=: status

Communication domain

Domain specifies the communication domain to be used (only Internet domain is supported).

Socket type

Type indicates the type of communication over the socket, and


Page 26

Protocol

The different socket types and their values are shown in the following table.

TYPE VALUE USE Default protocol Comments
SOCK_stream 1 stream socket TCP
SOCK_dgram 2 datagram socket UDP
SOCK_raw 3 raw-protocol interface Not supported
SOCK_rdm 4 reliably-delivered message Not supported
SOCK_seqpacket 5 sequenced packet stream Not supported

Table no. 2. Socket type

Internet Protocol

The different protocols and their values are shown in the table below:

TYPE VALUE Comment
in_pro_icmp 1 ICMP protocol
in_pro_tcp 6 TCP protocol
in_pro_udp 17 UDP protocol

Table no. 3. Internet Protocol Number

Internet Protocol

There is a default protocol for every domain/socket-type combination. For example, TCP provides virtual circuit service and UDP provides datagram services in the Internet domain.

An unconnected socket descriptor may yield a connected socket descriptor in one of two ways: either by actively connecting to another socket, or by becoming associated with a name in the communication domain and accepting a connection from another socket.


Page 27

Socket Binding

To accept connections, a socket must first be bound to a name within the communication domain. Such a bond is established by a bind call:

SLsockId   : Socket
SLsockaddr : name

SLbind(Socket, name) =: status

The bound name is a variable which is interpreted by the supporting protocol(s). Its interpretation may vary from one communication domain to another. A socket's bound name may be retrieved with a SLgetsockname call.

SLsockId   : Socket
SLsockaddr : name

SLgetsockname(Socket, name) =: status

SLgetpeername returns the name of the peer connected to the specified socket.

SLsockId   : Socket
SLsockaddr : name

SLgetpeername(Socket, name) =: status

For more information on binding addresses to sockets, see section 4.4, "Internet Address Binding".


Page 28

3.3. Accepting Connections

Listen

Once a bond is made, it is possible to listen for connections. You just specify the maximum number of outstanding connections (BackLog) which may be queued awaiting acceptance by the application.

SLSockId    : Socket
integer     : Backlog

2 =: Backlog
SLlisten(Socket, Backlog)=: status

After a socket has been obtained, the application program can either accept a connection from a remote socket or issue a connection request to a remote socket.

Accept connections

The SLaccept call returns a descriptor for a new, connected socket from the queue of pending connections.

SLSockId    : Socket, NewSocket
SLsockaddr  : NewAddr

SLaccept(Socket, NewSocket, NewAddr)=: status

3.4. Making Connections

Connect

An active connection to a named socket is made by the SLconnect call.

SLSockId    : Socket
SLsockaddr  : name

SLconnect(Socket, name)=: status

Page 29

3.5. Sending and Receiving Data

Send Data

When a connection is established, data may begin to flow. With the peer entity at each end of connection anchored, a user can send or receive a message without specifying the peer.

The SLsend is used to transmit a message from a socket to another socket. SLsend may be used only when the socket is in a connected state.

SLsockId  : Socket
BYTES     : TempBuf(0:4)
BYTE POINTER : Buf
INTEGER   : BufLen, returnLength
INTEGER   : flags

0 =: Flags
'Hello' =: TempBuf(0:4)
Addr(TempBuf(0)) =: Buf
5 =: BufLen
SLsend(Socket, Buf, BufLen, flags, returnLength)=: status

Receive Data

The SLrecv is used to receive messages from a socket. SLrecv may be used only when the socket is in a connected state.

SLsockId  : Socket
BYTES     : RecvBuf(0:4)
BYTE POINTER : Buf
INTEGER   : BufLen, returnLength
INTEGER   : flags

0 =: Flags
Addr(RecvBuf(0)) =: Buf
5 =: BufLen
SLrecv(Socket, Buf, BufLen, flags, returnLength)=: status

Page 30

3.6. Shutdown and Closing

Shutdown

The SLshutdown is used to shut down all or part of a full-duplex connection on the socket.

Applying shutdown to a socket causes any data queued to be immediately discarded.

SLsockId : Socket
integer  : how

2 =: how              % Shutdown both sides
SLshutdown(Socket, how) =: status

The parameter how indicates whether the sending side, the receiving side, or both sides no longer allow data transmission. It informs the underlying protocols to close down the network communications, but the sockets are still intact.

Close

Once a socket is no longer of interest, it may be discarded by applying a close to the descriptor. If data is associated with a socket which promises reliable delivery (such as a stream socket), when a close takes place the system will continue to attempt to transfer the data. If there is no use for any pending data, shutdown may be performed on the socket prior to closing it.

The SLclose call frees the socket descriptor.

SLsockId : Socket

SLclose(Socket) =: status

Page 31

3.7. Sleeping

SLsleep

To avoid waiting in the SLrecv call for incoming data, the SLsense call can be used to find out if any data is pending. If no data is available, an application can be suspended using the SLsleep call.

Applications are said to sleep on events, meaning they are in a sleep state until one or more events occur.

For more details about the event mechanism, see section 4.3.

INTEGER : EventMask
INTEGER : ActualEvents

- 1 =: EventMask           % All events. Wakes up applications
SLsleep(TimeInSeconds, EventMask, ActualEvents)

3.8. Datagram Sockets

Up to this point we presented sockets that make connections. It is also possible to create connectionless sockets which are typical of the datagram facility.

A datagram socket supports bidirectional flow of data, which is not promised to be sequenced, reliable, or non-duplicated. That is, a process receiving messages on a datagram socket may find messages duplicated, possibly in an order different from the order in which they were sent. Therefore, both communicating processes are responsible for retransmissions and acknowledgments of packets, in order to implement higher protocol layers.


Page 32

Socket Creation

Datagram sockets are created the same way as stream sockets:

INTEGER   : Domain, Type, Protocol
SLSockId  : NewSocket
AF_INET   =: Domain
SOCK_DGRAM =: Type
IN_PRO_UDP =: Protocol
SLsocket(domain, type, protocol, NewSocket) =: status

Each socket should have a name bound to it, so the receiver of the messages can identify the sender.

SLSocketID : Socket
SLSockAddr : name

SLbind(Socket, name) =: status

Send Data

The SLsendTo routine is used to send data:

SLsockID         : socket
BYTES            : TempBuf (0:4)
BYTE POINTER     : Buf
INTEGER          : BufLen, returnLength
INTEGER          : flags

$Lin_sockaddr POINTER : ToAddressP

0 =: Flags
'Hello' =: TempBuf (0:4)
Addr(TempBuf(0)) =: Buf
5 =: BufLen
Addr(ToAddress) =: ToAddressP

SLsendTo(socket, buf, bufLength, flags, ToAddressP, & 
returnLength) =: status

The parameter ToAddress is used to indicate the receiver's address of the message.


Page 33

SINTRAN SLIB Programmer's Guide

Receive Data

To receive data on an unconnected datagram socket, the SLrecvFrom routine is used.

SLsockID      : socket
BYTES         : TempBuf (0:4)
BYTE POINTER  : Buf
INTEGER       : BufLen, returnLength
INTEGER       : flags

SLrecvFrom(socket, buf, bufLength, flags, FromAddress, cc).

The FromAddr parameter specifies the address of the sender. In addition to the two calls mentioned above, datagram sockets can also use the SLconnect call to associate a socket with a specific address. In this case, any data sent on the socket is automatically addressed to the connected peer, and only data received from that peer is delivered to the user. Only one connected address is permitted for each socket (no multi-casting). Connect requests on datagram sockets return immediately, because the SLconnect simply results in the system recording the peer's address (as compared to a stream socket where a connect request initiates the establishment of an end-to-end connection).


Page 34

I'm sorry, but the page is blank. Could you provide a different scan or more information?


Page 35

Chapter 4.

ADVANCED TOPICS


Page 36

I'm sorry, but the page appears to be blank.


Page 37

4.1. Initializing Socket Library

SLinit

Socket Library must be initialized by the SLinit routine.

INTEGER2 ARRAY POINTER : WorkAreaP
SLmaxima              : initParam
SLrvvp                : task
INTEGER               : taskStackSize
INTEGER               : TaskDataP
SLinit(WorkAreaP, initParam, task, taskStackSize, taskDataP) =: status

The purpose of this call is to initialize a work area in the caller's data space for internal data structures used by SLIB. This call also makes contact with protocol servers.

4.1.1. WorkAreaP Parameter

WorkAreaP

The 'WorkAreaP' parameter is a pointer to a fixed area defined in the application with 'SLSzWorkArea' as size:

INTEGER2 ARRAY   : WorkArea(0:SLSzWorkArea-1)
Addr(WorkArea)  =: WorkAreaP

SLSzWorkArea is a constant defined in the SLIB:DEFS file. The value is calculated depending on the value of the following constants:

  • SLMaxPorts
  • SLMaxSockets
  • SLMainTaskStackSize
  • SLMaxSLFork
  • SLSubTaskStackSize

These constants are application dependent and must be defined before including the SLIB:DEFS file.


Page 38

Parameters

Parameter Description
SLMaxPorts Maximum number of ports. MUST BE EQUAL TO 1.
SLMaxSockets Maximum number of sockets created by the application.
SLMaxFork Maximum number of simultaneous subtasks.
SLSubTaskStackSize Average size of the stack used by a subtask. Note that you may have different subtasks using different stack sizes. The total stack used by all subtasks must not exceed the value "SLsubTaskStackSize * SLmaxFork".
SLMainTaskStackSize Stack size used by the maintask. For more details about tasks, see section 4.2.

4.1.2. initParam Parameter

The initParam parameter is of type SLmaxima, which is defined in the SLIB:DEFS file.

TYPE SLmaxima = RECORD
    INTEGER : max_nports
    INTEGER : max_nsockets
    BOOLEAN : max_debug
    INTEGER : max_debfd
    INTEGER POINTER POINTER : max_AUserDatap
    INTEGER : max_nsallocmsg
    INTEGER : max_nballocmsg
    INTEGER : max_tcpdev
ENDRECORD

This record is used to initialize the Socket Library.

  • max_nports
    Maximum number of ports. Must be equal to SLmaxPorts.
  • max_nsockets
    Maximum number of sockets. Must be equal to SLmaxSockets.

Page 39

SINTRAN SLJB Programmer's Guide

Parameters

max_debug

Flag to turn the debug mode ON or OFF.

max_debfd

File number to write the debug information to (1 for terminal). Used only if the flag max_debug is set.

max_AUserDatap

Address of user-data pointer. The following section gives more details about this parameter.

max_nsallocmsg

Number of small allocated messages reserved for the application during its lifetime. Those messages will be for internal messages between Socket Library and TCP. The messages also allow the application to send 30 bytes of data.

max_nballocmsg

Number of large allocated messages reserved for the application during its lifetime. These messages allow the application to send 1024 bytes of data.

The Socket Library does not allow an application to reserve more messages (max_nsallocmsg + max_nballocmsg) than the number of reserved sockets (max_nsockets).

+-------------------------+
| NOTE:                   |
|                         |
| These messages are      |
| system resource-dependent. |
+-------------------------+

max_tcpdev

This parameter is used to select the TCP device the application wants to connect to.


Page 40

TCP Device Selection

The application can let SLIB select a default TCP device to connect to or specify a specific TCP device. The values listed in the table below may be used:

TYPE VALUE Comment
SLDominoPioc -1 ①
SLPiocDomino -2 ②
SLDominoOnly -3 ③
SLPiocOnly -4 ④
0 ... 15 ⑤

Table no. 4. TCP devices

① SLIB selects a default device by first trying to contact TCP in Ethernet III (DOMINO), and if unsuccessful it tries to contact TCP in Ethernet II (PIOC). The first TCP device SLIB contacts is the one selected.

② SLIB selects a default device by first trying to contact TCP in Ethernet II (PIOC), and if unsuccessful it tries to contact TCP in Ethernet III (DOMINO). The first TCP device SLIB contacts is the one selected.

③ SLIB selects a default device. SLIB only tries to make contact with TCP in Ethernet III (DOMINO). The first TCP device SLIB contacts is the one selected.

④ SLIB selects a default device. SLIB only tries to make contact with TCP in Ethernet II (PIOC). The first TCP device SLIB contacts is the one selected.

⑤ A specific TCP device is selected.

If you are running the COSMOS TCP/IP Gateway for Ethernet II, the legal values are: 0 - 3.

If you are running the TCP/IP Basic Module for Ethernet III, the legal values are: 4 - 15.


Page 41

4.1.3. Other Parameters

Parameter Description
task Address of the maintask routine.
taskStackSize Size of the stack for the maintask routine.
taskDataP Pointer to a record associated with the task.

For more details about these parameters, see section 4.2.

4.2. Multitasking in SLIB

4.2.1. General Information

To compensate for the fact that SINTRAN does not have a fork system call like the UNIX operating system, multitasking has been implemented in SLIB.

Tasks can be created by the SLinit and SLfork calls. Each task uses a separate stack that is allocated from the storage area given in the SLinit call. The control of the tasks is hidden by SLIB.

When one task waits for messages or I/O, it is set in a wait queue. When messages arrive, the matching task is activated. A task ends its life when it calls SLexit or it passes through the ENDROUTINE statement of the associated task routine. We recommend the SLexit method.

Note that all tasks share some data, unlike processes in UNIX.


Page 42

4.2.2. How to Create Tasks

maintask

The maintask is the one created and activated by the SLinit call by giving the address of the associated routine.

ROUTINE VOID, VOID : MainTask
BYTES : Buffer(0:4)
...

SLsocket(AF_INET, SOCK_STREAM, 0, LocalSocket)
SLconnect(LocalSocket, RemoteSocketAddr)
'Hello' := Buffer
SLsend(LocalSocket, Addr(Buffer(0)), 5, 0, Length)
SLclose(LocalSocket)
SLexit

ENDROUTINE

ROUTINE VOID, VOID : DoSLinit

...

SLinit(Addr WorkArea, InitParam, Addr MainTask, &
SLMainTaskStackSize, NIL)

ENDROUTINE

subtask

Subtasks are the ones created and activated by the SLfork call. It is done in the same way as in the SLinit call.

In the example below, SLinit creates a task (MainTask), and activates it. This task creates a stream socket in the Internet domain and binds the socket to an address. To specify that this socket wants to receive connections, it first does a SLlisten and then a SLaccept call. This last call blocks until a connection request is done by another peer, and then it will return a new socket descriptor. A new task (subtask) is created by the SLfork call. For an example, see the following page.


Page 43

ForkExample

SockId : NewSocket

%====================================================%
%                     S u b T a s k                  %
%====================================================%

ROUTINE VOID,VOID : SubTask
    INTEGER : rstat, n
    BYTES   : Buffer(0:18)

    ON ASSERTFALSE DO PrintError(rstat);RETURN ENDON

    'This is the subtask' =: Buffer
    SLsend( newSocket, Addr(Buffer(0)),19,0,n) =: rstat
    ASSERT rstat = SLEok

    SLclose(newSocket) =: rstat
    ASSERT rstat = SLEok

    SLexit

ENDROUTINE.

Page 44

Main Task

ROUTINE VOID, VOID : MainTask

SLsockId       : socket
SLin_sockaddr  : myAddr, peerAddr
BYTES          : Buffer(0:20)
INTEGER        : RStat

ON ASSERTFALSE DO PrintError(rstat); RETURN ENDON

SLsocket(af_inet, sock_stream, 0, socket) =: RStat
ASSERT rstat = SLEok

0  =: myAddr.sin_addr.in_b1
0  =: myAddr.sin_addr.in_b2
0  =: myAddr.sin_addr.in_b3
0  =: myAddr.sin_addr.in_b4
af_inet =: myAddr.sa_family
513 =: myAddr.sin_port

SLbind(socket, myAddr) =: RStat
ASSERT rstat = SLEok

SLlisten(socket, .5) =: RStat
ASSERT rstat = SLEok

SLaccept(socket, newSocket, peerAddr) =: RStat
ASSERT rstat = SLEok

'This is the main task' =: Buffer
SLsend(newSocket, Addr(Buffer(0)), 21, 0, n) =: rstat
ASSERT rstat = SLEok

SLfork(Addr Subtask, SLSubTaskStackSize, NIL) =: RStat
ASSERT rstat = SLEok

ENDROUTINE

Page 45

Do S L i n i t

%===============================================================%
%                         D o S L i n i t                       %
%===============================================================%

ROUTINE VOID, VOID : DoSLinit

INTEGER : RStat             % return status
SLmaxima : InitParam        % max. values used in SLIB

ON ASSERTFALSE DO PrintError(rstat); RETURN ENDON

USING InitParam
    SLMaxPorts =: max_nports
    SLMaxSockets =: max_nsockets
    FALSE =: max_debug
    1 =: max_debfd
    1 =: max_nsallocmsg
    1 =: max_nballocmsg
ENDUSING

SLinit(Addr WorkArea, InitParam, MainTask, &
SLMainTaskStackSize, NIL) =: RStat
ASSERT rstat = SLEok

ENDROUTINE

ENDMODULE

4.2.3. Associating Data with the Tasks

It is possible to have a separate data area for each task by specifying the address of a record pointer in the SLinit call and the actual value of the pointer in SLfork call.

For every task switch, the pointer to the record is changed to the value given in SLfork.

In the example below, the pointer to the record associated with the task is specified in the SLinit call. When Maintask is activated, this task creates a socket in the Internet domain and binds it. To specify that this socket wants to receive connections, it does SLlisten and then waits until a record NextTaskDataP is free. When a new connection has been...


Page 46

Advanced Topics

ND-860372.1 EN

Accepted, it creates a new task DoEcho, which is the task that will be performed for this new connection. In the SLfork call, the address value of the record associated with this new task, NextTaskDataP, is specified.

Different subtasks can be associated with new connections. The stack needed by each of them is specified in the SLfork call.

Module UsingData

TYPE TaskDataType = RECORD
  SLsockid  : HisSocket
  SLin_sockaddr : HisAddr
  BYTES     : Buffer(0:1023)
  BOOLEAN   : InUse
ENDRECORD

TaskDataType : TaskData(0:MaxConnections-1)
TaskDataType POINTER : TaskDataP
%===================================================================%
% G e t N e x t D a t a R e c                                       %
%===================================================================%

ROUTINE VOID, TaskDataType POINTER : GetNexDataRec
  TaskDataType POINTER : p
  INTEGER : i

  NIL := p
  FOR i IN TaskData DO
    IF NOT TaskData(i).InUse THEN
      Addr(TaskData(i)) := p
      WHILE FALSE
    ENDIF
  ENDFOR
  IF p >< NIL THEN TRUE := p.InUse ENDIF

  p RETURN
ENDROUTINE

Page 47

DoEcho

%==============================================================%
% D o E c h o                                                  %
%==============================================================%
ROUTINE VOID,VOID : DoEcho
  INTEGER : rstat, sendLen, recvLen

  ON ASSERTFALSE DO
    SLclose(TaskDataP.hisSocket)
    SLexit
    PrintError(rstat)
    RETURN
  ENDON

  SLrecv(TaskDataP.hisSocket, Addr(TaskDataP.Buff(0)),&
    1024,0,recvLen) =: rstat
  ASSERT rstat = SLEok

  SLsend(TaskDataP.hisSocket, Addr(TaskDataP.Buffer(0)),&
    recvLen,0,sendLen) =: rstat
  ASSERT rstat = SLEok

  SLclose(TaskDataP.hisSocket)
  ASSERT rstat = SLEok
  FALSE =: TaskDataP.inUse
  SLexit

ENDROUTINE

Page 48

Main Task

ROUTINE VOID,VOID : MainTask

  SLsockId              : socket
  INTEGER               : RStat, Events
  TaskDataType POINTER  : NextTaskDataP

  ON ASSERTFALSE DO PrintError(rstat);RETURN ENDON

  SLsocket(af_inet, sock_stream, 0, socket) =: RStat
  ASSERT rstat = SLEok

  0 =: myAddr.sin_addr.in_b1
  0 =: myAddr.sin_addr.in_b2
  0 =: myAddr.sin_addr.in_b3
  0 =: myAddr.sin_addr.in_b4
  af_inet=: myAddr.sa_family
  SLhtons(7) =: myAddr.sin_port

  SLbind(socket, myAddr) =: RStat
  ASSERT rstat = SLEok

  SLlisten(socket, 5) =: RStat
  ASSERT rstat = SLEok

  DO
    DO
      GetNextDataRec =: NextTaskDataP
      WHILE NextTaskDataP = NIL
        SLsleep(10,-1,Events)
      ENDDO

      SLaccept(socket, NextTaskDataP.HisSocket, &
               NextTaskDataP.HisAddr) =: RStat
      ASSERT rstat = SLEok

      SLfork(Addr DoEcho, SLSubTaskStackSize, &
             NextTaskDataP FORCE INTEGER POINTER) =: RStat
      ASSERT rstat = SLEok
    ENDDO
  ENDDO

ENDROUTINE

Page 49

SINTRAN SLIB Programmer's Guide

ND-860372.1 EN

DosLinit

%===============================================%
% D o S L i n i t                               %
%===============================================%

ROUTINE VOID,VOID : DosLinit

    INTEGER : RStat                % return status
    SLMaxima : MaxVal              % max. values used in SLIB

    ON ASSERTFALSE DO PrintError(rstat);RETURN ENDON

    USING MaxVal
        SLMaxPorts   =: max_nports
        SLMaxSockets =: max_nsockets
        FALSE        =: max_debug
        1            =: max_defbd
        1            =: max_nsallocmsg
        1            =: max_nballocmsg
        Addr( TaskDataP) FORCE INTEGER POINTER POINTER =: &
                        max_AUserDataP
    ENDUSING

    SLinit(Addr WorkArea, InitParam, MainTask, &
           SLMainTaskStackSize, NIL) =: RStat
    ASSERT rstat = SLEok

ENDROUTINE

ENDMODULE

From this example, we will try to explain the activation/deactivation task mechanism.

The SLinit call creates a task MainTask. A pointer to the global variable TaskDataP is specified; it is the pointer to the record associated with the subtask.

MainTask blocks until a new connection from a remote peer is requested. When a new connection arrives, a first subtask (Task1) is created. In the SLfork call, the address of the pointer associated with the task is given TDP1.

Task1 is then activated (2), and blocks at the SLrecv call waiting for a message to arrive. Control is given to the MainTask (3).


Page 50

Advanced Topics

New Connection Request

Assuming that a new connection has been requested, at that time, a new subtask is created (Task2) with a new record pointer TDP2 (4). This task also blocks at the SLrecv call.

Assuming that meanwhile a message has been sent to Task1, this task is reactivated (5) and receives the message, and then sends it (6). The SLsend call blocks until SLIB receives an ACK from TCP. If a message arrived meanwhile for Task2, it is reactivated (7). Task2 then receives the message and sends it back (8). Again the SLsend blocks and the control is given back to Task1, which then does a SLclose (10). This last call blocks until SLIB receives an ACK from TCP, and so on.

See the figure below:

flowchart TD
    A[:::TDP] --> B[SLinit(Addr TDP)]
    B --> |(1)| C[MainTask]
    C --> |(2)| D[SLaccept]
    D --> E(SLfork(TDPx))
    E --> |(3)| F[Task1]
    E --> |(4)| G[Task2]
    F --> |TDP=TDP1| H
    G --> |TDP=TDP2| I
    H[SLrecv] --> |(6)| J[SLsend]
    I[SLrecv] --> |(5)| K
    K --> |(8)| L[SLsend]
    J --> |(10)| M[SLclose]
    L --> |(12)| N[SLclose]
    M --> |(11)| O
    N --> |(13)| P
    O[SLexit] --> |(14)| Q
    P[SLexit] --> |(16)| R
    Q --> |(15)| S
    R --> |(17)| T

Page 51

4.3. Event System

4.3.1. General Information

Tasks "go to sleep" because they are awaiting the occurrence of an event, such as waiting for I/O completion or system resources. Tasks sleep on events for a defined period, meaning they are in a "sleep" state until one or more events occur or a timeout occurs, at which time they "wake up" and continue their execution.

Different type of event are defined:

  • Socket events
  • External events
  • Own events

Several tasks can sleep simultaneously on the same event. When the event occurs, all tasks sleeping on that event wake up.

The events that wake up the task are returned in the actualEvents parameter.

CONSTANT SocketEvent    = 2**0
CONSTANT ExternalEvent  = 2**1
INTEGER : EventMask
INTEGER : ActualEvents
INTEGER : TimeInSeconds

SocketEvent + ExternalEvent =: EventMask
SLsleep(TimeInSeconds, EventMask, ActualEvents)

IF ActualEvents AND SocketEvent THEN
% read the message for this socket
ActualEvents XOR SocketEvent =: ActualEvents
ENDIF

Page 52

4.3.2. Setting an Event to a Socket

SLiocSOEV

To associate an event to a socket, the SLioctl must be used with the request SLiocSOEV (set socket event). When something happens on the socket, (for example, if a remote socket sent a message or was disconnected, or an error occurs), then the tasks waiting for this event are reactivated.

CONSTANT SocketEvent = 2**0
SLiocInt : Ioarg

SocketEvent =: IoArg.SLiocNumber
SLioctl(Socket, SLiocSOEV, Addr Ioarg, Size(Ioarg)) =: status

4.3.3. External Events

Tasks can go to sleep waiting for external events such as I/O completion from a peripheral device, system resources to become available and so on.

These events will be checked by the SLotherEvent routine. It is the application's responsibility to write this routine and export it. This routine should never be called by the application, but only by SLIB.

On the following page is an example of a possible SLotherEvent routine which checks if there is some input on a device.

IF ActualEvents AND ExternalEvent THEN
   % read the external message
   ActualEvents XOR ExternalEvent =: ExternalEvents
ENDIF

Page 53

SINTRAN SLIB Programmers Guide

EXPORT SLotherEvent

EXPORT    SLotherEvent
CONSTANT  ExternalEvent = 2**1

ROUTINE VOID, INTEGER4 : SLotherEvent
INTEGER : NoOfBytes

Monitor_Call('InBufferSpace', DeviceNumber, NoOfBytes)
  IF NoOfBytes > 0 THEN
    ExternalEvent RETURN
  ELSE
    0 RETURN
  ENDIF

ENDROUTINE

NOTE:

This routine should never be used by the application and should not call SLIB routines.

4.3.4 Own Events

Own events are used to activate other tasks. A typical use of this kind of event is task synchronization. An example is given on the following pages.


Page 54

MODULE OwnEVT

TaskDataType Record

TYPE TaskDataType = RECORD
  Slsockid    : HisSocket
  SLin_sockaddr : HisAddr
  BYTES       : Buffer(0: 1023)
  BOOLEAN     : InUse
ENDRECORD

Variables

  • TaskDataType : TaskData(0:MaxConnections-1)
  • TaskDataType POINTER : TaskDataP
  • BOOLEAN : Xlock
  • CONSTANT LockEVT = 2**3

Get Next Data Record

%=================================================================%
%   G e t N e x t D a t a R e c                                    %
%=================================================================%
ROUTINE VOID, TaskDataType POINTER : GetNextDataRec
  TaskDataType POINTER : p
  INTEGER : i

  NIL := p
  FOR i IN TaskData DO
    IF NOT TaskData(i).InUse THEN
      Addr(TaskData(i)) := p
      WHILE FALSE
    ENDIF
  ENDFOR
  IF p >< NIL THEN TRUE := p.InUse ENDIF

  p RETURN

ENDROUTINE

Unlock

%=================================================================%
%                           U n l o c k                           %
%=================================================================%
ROUTINE VOID, VOID : Unlock

  TRUE := Xlock

ENDROUTINE

Page 55

Lock

ROUTINE VOID; VOID : Lock

DO
    IF Xlock THEN
        FALSE =: Xlock
    WHILE FALSE
    ENDIF
    sleep(10, LockEVT)
ENDDO

ENDROUTINE

Synchronize

ROUTINE VOID, VOID : Synchronize
    INTEGER : rstat, sendLen, recvLen

    ON ASSERTFALSE DO
        SLclose(TaskDataP.hisSocket)
        SLexit
        PrintError(rstat)
        RETURN
    ENDON

    Lock

    SLsend(TaskDataP.hisSocket, Addr(TaskDataP.Buffer(0)), &
        recvLen, 0, sendLen) =: rstat
    ASSERT rstat = SLEok

    SLrecv(TaskDataP.hisSocket, Addr(TaskDataP.Buff(0)), &
        1024, 0, recvLen) =: rstat
    ASSERT rstat = SLEok

    SLSetOwnEvent(LockEVT)

    Unlock

ENDROUTINE

Page 56

Main Task

%=============================================================================%
% M a i n T a s k                                                             %
%=============================================================================%

ROUTINE VOID, VOID : MainTask

   SLsockId                              : socket
   INTEGER                                : RStat, Events
   TaskDataType POINTER : NextTaskDataP

   ON ASSERTFALSE DO PrintError(rstat); RETURN ENDON

   SLsocket(af_inet, sock_stream, 0, socket) =: RStat
   ASSERT rstat = SLEok

   0 =: myAddr.sin_addr.in_b1
   0 =: myAddr.sin_addr.in_b2
   0 =: myAddr.sin_addr.in_b3
   0 =: myAddr.sin_addr.in_b4
   af_inet =: myAddr.sa_family
   513 =: myAddr.sin_port

   SLbind(socket, myAddr) =: RStat
   ASSERT rstat = SLEok

   SLlisten(socket, 5) =: RStat
   ASSERT rstat = SLEok

   DO
   DO
      GetNextDataRec =: NextTaskDataP
      WHILE NextTaskDataP = NIL
         SLsleep(10, -1, Events)
      ENDDO

      SLaccept(socket, NextTaskDataP.HisSocket, &
               NextTaskDataP.HisAddr) =: RStat
      ASSERT rstat = SLEok

      SLfork(Addr Synchronize, SLSubTaskStackSize, &
             NextTaskDataP FORCE INTEGER POINTER) =: RStat
      ASSERT rstat = SLEok
   ENDDO

ENDROUTINE

Page 57

DoS Linit

%===============================================================%
%                          DoSLinit                             %
%===============================================================%

ROUTINE VOID, VOID : DoSLinit

Variable Description
INTEGER : RStat % Return status
SLmaxima : MaxVal % Max. values used in SLIB

ON ASSERTFALSE DO PrintError(rstat); RETURN ENDON

USING MaxVal

  • SLMaxPorts =: max_nports
  • SLMaxSockets =: max_nsockets
  • SLTraceOn =: max_debug
  • OutLogFile =: max_debfd
  • 1 =: max_nsallocmsg
  • 1 =: max_nballocmsg

Addr(TaskDataP) FORCE INTEGER POINTER POINTER =: & - max_AUserDataP

SLDominoPioc =: max_tcpdev

ENDUSING

SLinit(Addr socketHeap, MaxVal, MainTask, 6, SLMainTaskStackSize, NIL) =: RStat ASSERT rstat = SLEok.

ENDROUTINE


Page 58

4.4. Internet Address Binding

Binding addresses to sockets in the Internet domain can be fairly complex. Communicating processes are bound by an association. An association is composed of local and foreign addresses, and local and foreign ports. Port numbers are allocated out of separate spaces, one for each Internet protocol. Associations are always unique. That is, there can never be duplicate <protocol, local address, local port, foreign address, foreign port> combinations.

The bind system call allows a process to specify half of an association, <local address, local port>, while the connect and accept primitives are used to complete a socket's association. Since the association is created in two steps, the association uniqueness requirement indicated above could be violated unless care is taken.

Further, it is unrealistic to expect user programs to always know the proper values to use for the local address and local port, since a host can reside on multiple networks and the set of allocated port numbers is not directly accessible to a user.

To simplify local address binding, the notion of a 'wildcard' address has been provided. When an address is not specified (specified as 0 (zero)), the system interprets the address as 'any valid address'. For example, to bind a specific port number to a socket, but leave the local address unspecified, the following code might be used:


Page 59

SINTRAN SLIB Programmer's Guide

ND-860372.1 EN

Routine VOID,VOID : SocketBinding

Variable Description
SLockid : Socket
SLin_sockaddr : sin % Socket address
SLservent : thisservice& % Service specification for TCP/TELNET
SLservent POINTER : sp % Pointer on the service specification
INTEGER : RStat % Return status

ON ASSERTFALSE DO - PrintError(rstat) - RETURN - ENDON

0 -=: sin.Sin_addr.in_11  % Wildcard address

Get Service By Name

SLGByName('telnet',Addr'tcp') =: sp
IF sp = NIL THEN
  RETURN
ENDIF
Ind{sp} =: thisService
sp.s_port =: sin.sin_port
af_inet =: sin.sa_family

Create socket

SLsocket(sin.sa_family, sock_stream, 0, Socket)-=: RStat
ASSERT Rstat = SLEok

Bind socket

SLbind(Socket, sin) =: RStat
ASSERT Rstat = SLEok
SLclose(socket) =: rstat
ASSERT rstat = SLEok

ENDROUTINE


Page 60

Advanced Topics

Sockets with 'wildcard' local addresses may receive messages directed to the specific port number, and addressed to any of the possible addresses assigned to a host. For example, if a host is on networks 46 and 10 and a socket is bound as above, then an accept call is performed. The process will be able to accept connection requests which arrive from either network 46 or network 10.

In a similar fashion, a local port may be left unspecified (specified as zero), in which case the system will select an appropriate port number for it. See the example on the following page.


Page 61

SINTRAN SLIB Programmers Guide

ND-860372.1 EN

ROUTINE VOID, VOID : SocketBinding

SLsockid        : Socket
SLin_sockaddr   : sin    % Socket address
SLservent       : thisservice
SLservent POINTER : sp   % Pointer on the service specification
INTEGER         : RStat  % Return status

ON ASSERTFALSE DO PrintError(rstat) RETURN ENDON

MyLocalAddress =: sin.Sin_addr.in_l1   % Specifying the local address
0             =: sin.sin_port         % Unspecified port
af_inet       =: sin.sa_family
% Create socket
%
SLsocket(sin.sa_family, sock_stream, 0, Socket) =: RStat
ASSERT Rstat = SLEok
% Bind socket
%
SLbind(Socket, sin) =: RStat
ASSERT Rstat = SLEok
SLclose(socket) =: rstat
ASSERT rstat = SLEok

ENDROUTINE


Page 62

Select Port Number

The system selects the port number based on two criteria. The first is that ports numbered 0 through 1023 are reserved for privileged users. The second is that the port number should not be currently bound to another socket.

The restriction on allocating ports allows processes in a secure environment to perform verification on the originating address and port number.

Reuse Socket Address

In certain cases, the algorithm used by the system in selecting port numbers is unsuitable for an application. This is due to associations being created in a two-step process. For example, the Internet file transfer protocol (FTP) specifies that data connections must always originate from the same local port. However, duplicate associations are avoided by connecting to different foreign ports. In this situation, the system does not allow binding the same local address and port number to a socket if a previous data connection's socket still exists. To override the default port selection algorithm, perform an option call prior to address binding.

See the example on the following two pages.


Page 63

SINTRAN SLIIB Programmers Guide

ND-860372.1 EN

ROUTINE VOID, VOID: ReuseAddress

SLsockid        : socket1, socket2
SLin_sockaddr   : my_addr1, my_addr2
INTEGER         : RStat

ON ASSERTFALSE DO
    PrintError(rstat)
    RETURN
ENDON

SLgSByName('ftp', Addr'tcp') =: sp
IF sp = NIL THEN
    RETURN
ENDIF

sp.s_port =: my_addr1.sin_port
af_inet =: my_addr1.sa_family

%
% Create a socket
%
SLsocket(af_inet, sock_stream, 0, socket1) =: RStat
ASSERT rstat = SLE0k

%
% Bind the socket to a specific port
%
SLbind(socket, my_addr1) =: RStat
ASSERT rstat = SLE0k

%
% Create a new socket
%
SLsocket(af_inet, sock_stream, 0, socket2) =: RStat
IF RStat >< SLE0k THEN
    rstat RETURN
ENDIF

Page 64

Advanced Topics

ND-860372.1 EN

%
% Tell TCP to allow binding to a name already used
%

SLsetOption(socket2, sol_socket, so_reuseaddr , NIL, 0) =: RStat
ASSERT RStat = SLEOK

af_inet =: my_addr2.sa_family
my_addr1.sin_addr =: my_addr2.sin_addr
my_addr1.s_port   =: my_addr2.sin_port

SLbind(socket2, my_addr2) =: RStat
ASSERT RStat = SLEOK

SLclose(socket1) =: rstat
ASSERT rstat = SLEok

SLclose(socket2) =: rstat
ASSERT rstat = SLEok

ENDROUTINE

Page 65

SINTRAN SLIIB Programmers Guide

ND-860372.1 EN

With the previous call, local addresses already in use may be bound. This does not violate the uniqueness requirement, as the system still checks at connection time to be sure any other socket with the same local address and port does not have the same foreign address and port (if an association already exists, the error SLEaddrInUse is returned).

4.5. SIoctl Routine

The SIoctl routine performs a variety of functions on sockets.

The table below lists the different available functions:

FUNCTION VALUE USE
SLIocNBIO 1 Set/reset nonblocking IO
SLIocSNOACT 2 Set no activity timer
SLIocGNOACT 3 Get no activity timer
SLIocSOEV 4 Set event bits for the socket
SLIocSSEV 5 Internal use
SLIocGActConn 6 Get active connections
SLIocGMbStat 7 Get mbuf stat
SLIocGNetwork 8 Get network statistics
SLIocGArpTable 9 Get arp table
SLIocGHwStat 10 Get hardware statistics
SLIocGGenInfo 11 Get generation information
SLIocGLoad 12 Get load information
SLIocSAipAddr 13 Set AIP address
SLIocKill 14 Kill SLIap
SLIocGTimers 15 Get timer information
SLIocDIEV 16 Internal use
SLIocSndQue 17 Internal use

Table no. 5. SLIocCTL Functions


Page 66

4.5.1. Nonblocking Option

This request sets or resets nonblocking I/O. It may have the following values:

VALUE EFFECT
0 Nonblocking I/O disabled
1 Nonblocking I/O enabled

Example

ROUTINE VOID,VOID: ResetBlockingIO

  SLsockid          : socket
  INTEGER2          : rstat.
  SLiocInt          : IoArg

  ON ASSERTFALSE DO
    PrintError(rstat)
    RETURN
  ENDON

  SLsocket(af_inet,sock_stream,0,socket) =: rstat
  ASSERT rstat = SLeok

  % Reset nonblocking option this Socket
  0 =: IoArg.SliocNumber          % No Wait OFF

  SLioctl(socket,SliocNBIO,Addr IoArg,Size(IoArg)) =: rstat
  IF rstat >< SLeok THEN
    PrintError(rstat)
  ENDIF

  SLclose(socket) =: rstat
  ASSERT rstat = SLeok

ENDROUTINE

Page 67

4.5.2. No Activity Timer

Two I/O control functions are available:

  • SLIocSNOACT: set no activity timer
  • SLIocGNOACT: get no activity timer

Function

The TCP has several timers running, each taking care of a special situation. One of these timers concerns idle connections. If an established connection is idle for several hours, it is holding resources for no use. The 'no activity timer' is therefore running, enabling TCP to take action whenever a connection has been idle for a certain time. Both the idle time in seconds and the actions performed by the TCP can be redefined by the application. There are two possible actions to perform; however, a connection has these default values:

Whenever 600 seconds have elapsed without anything happening on the specified connection, the specified action is performed.

  • signal remote peer is enabled
  • signal the local application is disabled

Explanation of the Actions

1) signal remote peer

A TCP segment with one byte of data previously sent will be retransmitted, setting the sequence and acknowledgment numbers in the TCP protocol header in such a way that forces the remote TCP to answer the segment if its end of the connection is still alive. Both the request and answer have the function of only telling if there is still a path open between the two TCP ports.


Page 68

2) Signal the Application

Whenever the timer expires, a signal consisting of an error message (TcpEtimedout) will be given to the Socket Library which returns the value SLEtimedOut to the application. It will thereafter be the responsibility of the application to take further action.

However, if the 'signal remote peer' signal is enabled, and the TCP is not receiving any answer, it retransmits with intervals of 1, 2, 4, 8, 16 and 32 seconds. If the TCP is still not receiving any answer, it will signal the application with the TcpEtimedout error message, regardless of whether the 'signal the application' is enabled.

Noactivity Timer

In other words, an application may use the Noactivity timer for its own purpose, but the default values allow the timer to function as a keep-alive function. Every 10 minutes, the TCP will check if the remote peer is still alive. If it is, nothing further happens until the next occurrence of the Noactivity timer or data starts to be sent on the connection. If the remote peer does not answer, the application is signaled with a timeout error as mentioned.

The parameter for the SLioCSNoact and SLioCGNoact parameters is a packed record of two 16-bit integers:

    31              16 15             1 0
+---------------+----------------+---+---+
|     Value     |    Not Used    | B | A |
+---------------+----------------+---+---+

Value

Periodicity of the NOACTIVITY occurrence is in seconds.

BIT A

If this bit is set, TCP, after a period of no activity from the peer, sends a signal to it. If there is no answer from the peer, TCP will retransmit this signal after 2, 4, 8, 16 seconds. If there is still no answer, the application is signaled by a TimeOut error. The application is then expected to close the connection.


Page 69

BIT B

If this bit is set, TCP signals the application whenever the NOACTIVITY timer occurs. However, the retransmit timeout signal cannot be disabled.

Example

If an application wants to be signalled when the NO ACTIVITY occurs after 60 seconds, then

  • Value = 60
  • Bit A = 0
  • Bit B = 1

The SLocInt record has one parameter declared as INTEGER4. The parameter IOarg is thus set in the following way:

ROUTINE VOID,VOID : Activitytimer
SLocINT : IOarg

60 SHIFT 16 + 2 =: IOarg.SLocNumber  % Integer4
SLocltl(socket,SLocSNOACT,Addr IOarg, size(IOarg) )

ENROUTINE

Page 70

4.5.3. Set an Event Bit on a Socket

Details on sockets events were given in the previous section.

Example

ROUTINE VOID, VOID: SetSocketEvent
    CONSTANT SocketEvent = 2**0
    SLsockid : socket
    INTEGER2 : rstat
    SLiocInt : IoArg

    ON ASSERTFALSE DO
        PrintError(rstat)
        RETURN
    ENDON

    SLsocket(af_inet, sock_stream, 0, socket) =: rstat
    ASSERT rstat = SLEok

    SocketEvent =: IoArg.SLlocNumber
    SLioctl(socket, SLlocSOEV, Addr IoArg, Size(Ioarg)) =: rstat
    IF rstat >< SLEok THEN
        PrintError(rstat)
    ENDIF

    SLclose(socket) =: rstat
    ASSERT rstat = SLEok

ENDROUTINE

4.5.4. Network Status

Several functions allow the Socket Library to fetch the status of TCP/IP. The functions currently available are:

  • Get active connections
  • Get mbuf statistics
  • Get network statistics
  • Get arp table
  • Get hardware statistics

Page 71

4.5.4.1. Get Active Connections

SLocGActConn

The TCP keeps a record of each connection, called a Socket Library Access Point (SlAp).

The SLocActConn record contains special selected information for one of these SlAp's. The TCP keeps active connections in a special queue, from which SLocActConn requests are serviced. The SLocActConn requests must contain the address of the SlAp to fetch information from. By specifying 0, one will get information about the first SlAp in the active queue and an address for the next SlAp in the queue. The information is given in blocks of 40 bytes.

The record of type SLocActConn, defined in the SLIB:DEFS file, describes this information:

SLocActConn, record description

TYPE SLocActConn = SLocArg RECORD PACKED
    INTEGER4: STAaddr
    INTEGER4: STAnext
    INTEGER2: STArcvQ
    INTEGER2: STAsndQ
    SLin_sockaddr: STA1addr
    SLin_sockaddr: STAFAaddr
    INTEGER2: STAconid
    BYTE: STAproto
    BYTE: STAstate
    INTEGER4: STAsbytes
    INTEGER4: STARbytes
    BYTES: STAbytes(0:39) = STAaddr
ENDRECORD

Page 72

Parameter Description

Parameter Description
STAaddr On input, the address of the requested SIAp. On response, the actual address may be different than requested. May be zero both ways.
STAnext Response: gives address of next SIAp in active queue. Will be zero if this SIAp is the last one in active queue.
STArcvQ Response: contains the number of bytes in the receive queue for this connection.
SRAsndQ Response: contains the number of bytes in the send queue for this connection.
STA1addr Response: contains the socket address of the local side of the connection.
STAfaddr Response: contains the socket address of the remote side of the connection.
STAconid Response: contains a special assigned identifier for the interface between the SIAp and the socket.
STAproto Response: contains the number of the protocol currently assigned to the protocol. See table 3.
STAstate Response: contains the number of the TCP state of the connection. See table 6.
STASbytes Response: contains the total number of bytes sent on this connection.
STARbytes Response: contains the total number of bytes received on this connection.

Page 73

TCP State

A connection progresses through a series of states during its lifetime. The TCP connection states are defined as:

STA state TCP state Comments
0 SAME The connection is idle
1 LISTEN Waiting for a connection request from any remote TCP and port.
2 SYN_SENT Waiting for a matching connection request after having sent a connection request.
3 SYN_RCVD Waiting for a confirming connection request acknowledgment after having both received and sent a connection request.
4 L_SYN_RCVD Waiting for a confirming connection acknowledgment after having both received a connection request and sent a confirming connection request acknowledgment.
5 ESTABLISHED An established open connection, ready to transmit and receive data.
6 FIN_W1 Waiting for a connection termination request from the remote TCP, or an acknowledgment of the connection termination request previously sent.
7 FIN_W2 Waiting for a connection termination request from the remote TCP.
8 TIME_WAIT Waiting for enough time to pass to be sure the remote TCP received the acknowledgment of its connection termination request.
9 CLOSE_WAIT Waiting for a connection termination request from the local user.

Continued on the following page.


Page 74

TCP State Table

STA State TCP State Comments
10 CLOSING1 Waiting for a connection termination request acknowledgment from the remote TCP.
11 CLOSING2 Waiting for a connection termination request acknowledgment from the remote TCP.
12 RCV_WAIT
13 CLOSED No connection state at all; is fictional because it represents the state when there is no TCB, and therefore, no connection.
14 EFAILEC Not really a connection state; used to represent receipt of an unacceptable segment.

Table no. 6. TCP state


Page 75

Example

ROUTINE VOID,VOID : ListNetStatus

SLsockid: socket
INTEGER2: rstat, szData
SLiocArg POINTER: theData
SLiocActConn POINTER: theActConn = theData
BOOLEAN : firstConn

0 =: rstat

ON ASSERT#FALSE DO
    PrintError(rstat)
    RETURN
ENDON

SLsocket(af_inet,sock_stream,0,socket) =: rstat
ASSERT rstat = SLEok

Addr(bufA(0)) FORCE SLiocArg POINTER =: theData

0 =: theActConn.STAaddr    % Start with this one
TRUE =: firstConn

DO
    Size(SLlocActConn) =: szData
    SLioctl(socket,SLiocGActConn,theData,szData) =: rstat
    ASSERT rstat = SLEok

    WHILE theActConn.STAaddr >< 0   % Valid connection?
        PrintActConn(theActConn,szData,firstConn)

    WHILE theActConn.STAnext >< 0   % Not end of list?
        FALSE =: firstConn
        theActConn.STAnext =: theActConn.STAaddr  % Try next connection
ENDDO

ENDROUTINE

Page 76

4.5.4.2. Get Hardware Statistics

SLocGHwStat
Show the state of interfaces which have been auto-configurated.

SLOcLNMAST, record description

TYPE SLocLNMAST = SLocArg RECORD PACK
  LNMAStype: LNMAS \type
  BYTE:       LNMAS \Version
  INTEGER4:   ENMAS \Transmitted

  INTEGER4:   ENMAS \ToneCollision
  INTEGER4:   ENMAS \MultiCollision
  INTEGER2:   ENMAS \Aborted
  INTEGER4:   ENMAS \Received
  INTEGER4:   ENMAS \Dropped
  INTEGER4:   ENMAS \Missed
  INTEGER2:   ENMAS \CrcErrors
  INTEGER2:   ENMAS \AlignErrors
  INTEGER2:   ENMAS \FifoOverflow
  INTEGER2:   ENMAS \Overflow
  INTEGER2:   ENMAS \BadMALength

  INTEGER2:   ENMAS \Restarts
  INTEGER2:   ENMAS \LossOfCarrier
  INTEGER2:   ENMAS \BadLength

  INTEGER2:   ENMAS \BadAddress

  INTEGER2:   ENMAS \Jabber
  INTEGER2:   ENMAS \Underflow
  INTEGER2:   ENMAS \LateCollision
  INTEGER2:   ENMAS \HeartbeatGone
  INTEGER2:   ENMAS \MemoryError
  INTEGER2:   ENMAS \HangingTransmit
ENDRECORD

With (see following page):


Page 77

SINTRAN SLIB Programmers Guide

ND-860372.1 EN

TYPE LNMAtype = ENUMERATION(LNMA2cardEthernet,     % Original Ethernet
                             LNMAlanceEthernet,    % LANCE Ethernet
                             LNMAtokenRing,        % Token ring interface
                             LNMAtokenBus,         % Token bus interface
                             LNMAfddi)

Parameter Description

Parameter Description
ENMAStype Interface type
LNMASTversion Version
ENMASTtransmitted Total successful transmissions
ENMASToneCollision Transmitted after one collision
ENMASTmultiCollision Transmitted after multiple collisions
ENMASTaborted Aborted transmission (too many collisions)
ENMASTreceived Frames received and sent to user
ENMASTdropped Dropped since no user receive request
ENMASTmissed No buffer for receive frame
ENMASTcrcErrors Received with bad crc
ENMASTalignErrors Octet alignment errors
ENMASTfifoOverflow Internal FIFO overflow
ENMASToverflow Incoming frame exceeded buffer length
ENMASTbadMAlength MA length field not in accord with frame length
ENMASTrestarts Number of restarts performed by ENMA
ENMASTlossOfCarrier Carrier lost during transmit

Page 78

Advanced Topics

Code Description
ENMASTbadLength Bad received frame length read
ENMASTbadAddress Frame received, should not have passed check
ENMASTjabber Jabber detected
ENMASTunderflow Transmit underflow
ENMASTlateCollision Collision outside window, not sent
ENMASTheartbeat-Gone No heartbeat from transceiver
ENMASTmemoryError LANCE got no response in time
ENMASThanging-Transmit Transmit channel hung

Page 79

Example

%===========================================================%
%  List Net Status                                           %
%===========================================================%

ROUTINE VOID,VOID : ListNetStatus

SLsocket: socket
INTEGER: rstat, szData
SliocArg POINTER: theData
SliocActConn POINTER: theActConn = theData

    SliocLNMAST POINTER: theLnmast = theData
    BYTES POINTER: theParam, default
    BOOLEAN : firstConn

    0 =: rstat.

    ON ASSERTFALSE DO
        PrintError(rstat)
        RETURN
    ENDON

    SLsocket(af_inet,sock_stream,0,socket) =: rstat
    ASSERT rstat = SLEok

    Addr(bufA(0)) FORCE SliocArg POINTER =: theData

    SLioctl(socket,SliocGHwStat,theData,max_lnma_stat_size) =: rstat
    ASSERT rstat = SLEok

    PrintHWstat(theLnmast,szData)

ENDROUTINE

4.5.4.3. Get mbuf Statistics

SliocGMbStat

The SliocGMbStat function retrieves statistics recorded by the memory management.

The record of type SliocMbStat, defined in the SLIB:DEFS file, describes the mbuf statistics. The Message Buffer Control Blocks (MBUF) are reserved by both TCP and IP (Internet


Page 80

SLiocMbStat Record Description

TYPE SliocMbStat = SLiocArg RECORD
    INTEGER  : mb_mbufs
    INTEGER2 : mb_mfree
    INTEGER2 : mb_mdrops
    INTEGER2 ARRAY: mb_mtypes(0:mt_max_val)
    INTEGER2 ARRAY: mb_mtdrop(0:mt_max_val)
    BYTES : mb_mbytes(0:Size(SLiocMbStat)-1) = mb_mbufs
ENDRECORD

Parameter Description

Type Value Comments
mb_mbufs mbufs obtained from page pool
mb_mfree mbufs in free list
mb_mdrops Number of times TCP failed to get a buffer
mb_mtype Type specific to mbuf allocation
mt_free 0 Buffers not reserved
mt_data 1 Buffers for receiving data from SLIIB
mt_header 2 Buffers for sending data to IP
mt_dynamic 3 Buffers for receiving data from IP
mt_rvcoob 4 Not in use
mt_extcoob 5 Buffers for receiving out-of-band data
mt_userdata 6 Buffers used by the UDP protocol
mt_arp 7 Buffers used for the ARP protocol
mt_digm 8 Buffers used by IP
mb_mtdrop Number of times TCP failed to get a buffer of
a specific type

Table no. 7. mbuf types


Page 81

Example

%==============================================%
% L i s t N e t S t a t u s %
%==============================================%
ROUTINE VOID,VOID. : ListNetStatus

  SLsockid: socket
  INTEGER2: rstat, szData
  SLiocArg POINTER: theData

  SliocMbStat POINTER: theMbstat = theData
  BYTES POINTER: theParam, default
  BOOLEAN : firstConn

  0 =: rstat

  ON ASSERTFALSE DO
    PrintError(rstat)
    RETURN
  ENDON

  SLsocket(af_inet, sock_stream, 0, socket) =: rstat
  ASSERT rstat = SLEok

  Addr(bufA(0)) FORCE SliocArg POINTER =: theData

  Size(SliocMbStat) =: szData
  SLiocl(socket, SLiocGmbstat, theData, szData) =: rstat
  ASSERT rstat = SLEok

  PrintMbStat(theMbstat, szData)

ENDROUTINE

Page 82

4.5.4.4. Get Network Statistics

SLiocGNetwork

The SLioGNetwork function retrieves network statistics. It is described by the record SLiocNetwork, which is defined in the SLIB:DEFS file.

SLiocNetwork, record description

TYPE SLiocNetwork = SLiocArg RECORD
    INTEGER4: ip_total
    INTEGER4: ip_badsum
    INTEGER4: ip_tooshort
    INTEGER4: ip_drops
    INTEGER4: ip_forwarded
    INTEGER4: ip_broadcast

    INTEGER4: t_total
    INTEGER4: t_sndtotal
    INTEGER4: t_badsum
    INTEGER4: t_tooshort
    INTEGER4: t_badsegs
    INTEGER4: t_unack
    INTEGER4: t_retransmit
    INTEGER4: t_ackonly

    INTEGER4: ic_total
    INTEGER4: ic_badsum
    INTEGER4: ic_tooshort
    INTEGER4: ic_broadcast
    INTEGER4: ic_drops
    INTEGER4: ic_quenches
    INTEGER4: ic_redirects
    INTEGER4: ic_echoes
    INTEGER4: ic_svpings
    INTEGER4: ic_pings
    INTEGER4: ic_timex
    INTEGER4: ic_parm

    INTEGER4: u_total
    INTEGER4: u_sndtotal
    INTEGER4: u_badsum
    INTEGER4: u_tooshort
    INTEGER4: u_drops
    INTEGER4: u_sonospace
    INTEGER4: u_nobuf

Page 83

SINTRAN SLIB Programmers Guide

INTEGERS

INTEGER4: o_total

BYTES: nS_bytes(0:Size(SilocNetwork)-1) = ip_total

ENDRECORD

Parameter Description

IP Description

Parameter Description
ip_total TCP packets received.
ip_badsum Bad IP checksum.
ip_tooshort Failed memory requests.
ip_drops Dropped packets.
ip_forwarded Forwarded packets.
ip_broadcast Broadcast packets.

TCP Description

Parameter Description
t_total TCP packet received.
t_sndtotal TCP packets sent.
t_badsum Packet received with bad checksum.
t_tooshort TCP has received a packet smaller than the size of header.
t_badsegs The packet was sent to a connection which was not in a state to receive it (perhaps a packet was received on a closed connection).

Page 84

TCP Descriptions

t_unack

Segments received on connections where our window size was zero (we could not receive the data, so we placed it in a queue to wait for free buffers).

t_retransmit

Packets retransmitted after timeout.

t_ackonly

ACK sent by TCP.

ICMP Description

Code Description
ic_pings Pings actually sent.
ic_total Total ICMP packets received.
Not implemented.
ic_badsum Bad ICMP checksum.
Not implemented.
ic_tooshort ICMP failed memory request.
Not implemented.
ic_broadcast ICMP packets rcvd that were broadcast (ignored).
Not implemented.
ic_drops ICMP message with invalid type (ignored).
Not implemented.
ic_quenches ICMP source quenches received.
Not implemented.
ic_redirecticmp ICMP redirects received.
Not implemented.
ic_echoes ICMP echo request responded to.
Not implemented.

Page 85

SINTRAN SLiB Programmers Guide

ND-860372.1 EN

Description Status
ic_svpings
Pings received.
Not implemented.
ic_timex
ICMP time exceeded messages received.
Not implemented.
ic_parm
ICMP parameter problems received.
Not implemented.

UDP Description

Not implemented.


Page 86

Example

%============================================================================%
%                           ListNetStatus                                    %
%============================================================================%
ROUTINE VOID,VOID  :  ListNetStatus  

    SLsockid: socket
    INTEGER2: rstat, szData
    SliocArg POINTER: theData
    SliocNetwork POINTER: theNetstat = theData
    BOOLEAN : firstConn

    0 =: rstat

    ON ASSERTFALSE DO
        PrintError(rstat)
        RETURN
    ENDON 

    SLsocket(af_inet,sock_stream,0,socket) =: rstat
    ASSERT rstat = SLEok

    Addr(bufA(0)) FORCE SliocArg POINTER =: theData

    Size(SliocNetwork) =: szData
    SLioctl(socket,SliocGNetwork,theData,szData) =: rstat
    ASSERT rstat = SLEok

    PrintNetStat(theNetstat,szData).

ENDROUTINE

4.5.5. Get ARP Table

SliocGArpTable

The SliocGArpTable function retrieves the ARP table giving the mapping between the Internet address and the Ethernet address. Only remote hosts that have sent to/received from our local host since the last restart of the local TCP/IP are in the ARP table.

This I/O request retrieves the ARP table. It is described by the record of type SliocGArpTable defined in the SLIB:DEFS file.


Page 87

SINTRAN SLIB Programmers Guide

SLocArpTable, record description

TYPE SLocArpTable = SLocArg RECORD PACKED
  INTEGER2:  TARPinterf
  INTEGER4:  TARPipAddr
  BYTES   :  TARPethAddr(0:5)
  BYTES   :  TARPbytes(0:11) = TARPinterf
ENDRECORD

Parameter description

Parameter Description
TARPinterf Interface number
TARPipAddr IP address
TARPethAddr Ethernet address

Example

ROUTINE VOID,VOID : DoArpWork

  SLsockid: socket
  INTEGER2: rstat, szData
  SLocArg POINTER: theData
  SLocArpTable POINTER: theTable = theData

  0 =: rstat

  ON ASSERTFALSE DO
    .PrintError(rstat)
    RETURN
  ENDON

  SLsocket(af_inet,sock_stream,0,socket) =: rstat
  ASSERT rstat = SLEok

  Addr(bufA{0}) FORCE SLocArg POINTER =: theData
  85 * Size(SLocArpTable) =: szData  $ max in 1024 bytes buffer
  SLioctl(socket,SLocGArptable,theData,szData) =: rstat
  ASSERT rstat = SLEok

  PrintArpTable(theTable,szData)

  SLclose(socket) =: rstat

Page 88

4.5.6. Get Generation Information

SliocGGenInfo

The SLiocGGenInfo function gives configuration information about the TCP/IP software. This information is described by the record of type SLiocGenInfo defined in the SLIB:DEFS file:

SLiocGenInfo, record description

TYPE SLiocGenInfo = SLiocArg RECORD PACKED.
    INTEGER4: GENconfig
    INTEGER4: GENconnections
    INTEGER4: GENmbufs
    INTEGER4: GENactiveTime
    INTEGER4: GENaipaddr
    INTEGER4: GENgatewayaddr
    INTEGER4: GENnetmask
    INTEGER4: GENdummy1
    INTEGER4: GENdummy2
    INTEGER4: GENdummy3
    BYTE    : GENlen1                    MOD 2
    BYTES   : GENdate(0:31)             MOD 2
    BYTE    : GENlen2                    MOD 2
    BYTES   : GENversion(0:5)           MOD 2
    BYTE    : GENlen3                    MOD 2
    BYTES   : GENsystem(0:15)           MOD 2
    BYTE    : GENlen4                    MOD 2
    BYTES   : GENportname(0:31)         MOD 2
    BYTE    : GENlen5                    MOD 2
    BYTES   : GENeventinfo(0:63)        MOD 2
    BYTE    : GENlen6                    MOD 2
    BYTES   : GENtext1(0:31)            MOD 2
    BYTE    : GENlen7                    MOD 2
    BYTES   : GENtext2(0:31)            MOD 2
    BYTE    : GENlen8                    MOD 2
    BYTES   : GENtext3(0:31)            MOD 2
    BYTE    : GENbytes(0:Size(SLiocGenInfo)-1) = GENconfig
ENDRECORD

Page 89

Parameter Description

Parameter Description
GENconfig Configuration mask
GENconnections Maximum number of connections
GENmbufs Maximum number of mbufs
GENactiveTime Number of seconds since TCP state
GENaipAddr AIP address
GENgatewayaddr Gateway address
GENnetmask Network mask
GENdummy1 Not used
GENdummy2 Not used
GENdummy3 Not used
GENlen1 Number of significant bytes in GENdate
GENdate Generation date (e.g. '1 April 1988')
GENlen2 Number of significant bytes in GENversion
GENversion Version (e.g. 'B00')
GENlen3 Number of significant bytes in GENsystem
GENsystem System (e.g. 'Ethernet II')
GENlen4 Number of significant bytes in GENportname
GENportname Port name (e.g. '*TCP')
GENlen5 Number of significant bytes in GENeventinfo

Page 90

Advanced Topics

GENeventInfo

Trace/statistics/error/netproblem event block

GENlen6

Number of significant bytes in GENext1

GENext1

Spare (not used).

GENlen7

Number of significant bytes in GENext2

GENext2

Not used

GENlen8

Number of significant bytes in GENext3

GENext3

Not used

Example

ROUTINE VOID,VOID: ListGenInfo

   SLsockid                 : socket
   INTEGER2                : rstat, szData
   SLiocArg POINTER        : theData
   SLiocGenInfor POINTER: TheTable = theData

   ON ASSERTFALSE DO
      PrintError(rstat)
      RETURN
   ENDON

   SLsocket(af_inet,sock_stream,0,socket) =: rstat
   ASSERT rstat = SLEoK

   Addr(bufA(0)) FORCE SLiocArg POINTER =: theData
   Size(SLiocGenInfo) =: szData
   SLioctl(socket,SLiocGGenInfo,theData,szData) =: rstat
   ASSERT rstat = SLEoK

   PrintGenInfo(theTable,szData)

   SLclose(socket) =: rstat
   ASSERT rstat = SLEoK
ENDROUTINE

Page 91

4.5.7. Get Load Information

SLiocGLoad

Load information is made for installations with two or more Ethernet controllers. Applications may then check each controller to find out which one is most heavily in use. This information is available as two numbers, each of size INTEGER2. They may be declared like this:

type ldrec = RECORD PACKED
    INTEGER2: p0, p1
ENDRECORD

The first parameter (p0), contains the current number of S1Ap's in use (listening and active connections). The second (p1), contains the total number of TCP and UDP packets sent and received per second on the whole controller. This is computed every 10 seconds; the value given in the SLioctl response is the last value computed, between 0 and 10 seconds ago. This is a crude measure of the load.

An example follows on the next page.


Page 92

Example

ROUTINE VOID,VOID: ListLoadInfo

INTEGER2: rstat
SLocArg POINTER: p
ldrec: ld
SLsockid: socket

ON ASSERTFALSE DO
    PrintError(rstat)
    RETURN
ENDON

0 =: rstat

SLsocket(af_inet,sock_stream,0,socket) =: rstat
ASSERT rstat = SLEok

Addr(ld) FORCE SLocArg POINTER =: p
SLioctl(socket,SliocGload,p,SIZE(ld)) =: rstat
ASSERT rstat = SLEok

Print('No. of connections',p0)
Print('No. of packets last 10 sec',p1)

SLclose(socket) =: rstat
ASSERT rstat = SLEok

ENDROUTINE

Page 93

4.5.8. Kill a Connection

SLocKill

The SLocKill function allows you to remove a connection in the TCP software without restarting the TCP/IP software, by giving the same TCP connection identifier as the one given by the SLocActConn function.

Example

ROUTINE VOID,VOID: killcmd

   SLsockid           : socket
   INTEGER2           : rstat, szData
   SLocArg POINTER    : theData
   SLocINT POINTER    : theTable = theData .
   INTEGER4           : slNo

   ON ASSERTFALSE DO
      PrintError(rstat)
      RETURN
   ENDON

   SLsocket(af_inet,sock_stream,0,socket) =: rstat
   ASSERT rstat = SLEok

   slNo =: theTable.SiLocNumber

   Size(silocINT) =: szData
   SLioctl(socket,SLocKill,theData,szData) =: rstat
   IF rstat >< SLEok THEN
      PrintError(rstat)
   ENDIF

   SLClose(socket) =: rstat
   ASSERT rstat = SLEok

ENDROUTINE

Page 94

The page appears to be blank except for a header and footer. There is no content to convert into Markdown, headings, tables, or diagrams.


Page 95

Chapter 5. NETWORK ADMINISTRATION FILES


Page 96

I'm sorry, the page appears to be blank.


Page 97

5.1. Introduction

All the following files are plain text files and have been created under user SYSTEM when installing the TCP/IP software.

5.2. AIP-HOSTS:SYMB - Host Name Database

AIP-HOSTS, file description
The AIP-HOSTS file contains information about the known hosts on the local Internet. For each host, a single line should be present with the following information:

Internet-Address Official-Host-Name Aliases

The official host name should be unique on the local network. A host may have a number of aliases, which need not be unique.

Items are separated by any number of blanks and/or tab characters. A "#" indicates the beginning of a comment; characters up to the end of line are not interpreted by routines which search the file.

Network addresses are specified in the conventional "." (dot) notation. Host names may contain any printable character other than a field delimiter, new line or comment.

On the following page is an example of the AIP-HOSTS:SYMB file.


Page 98

Example of an AIP-HOSTS:SYMB File

128.39.3.6   nd-hqrd-anton   anton
128.39.3.3   nd-hqrd-ole     ole       # Location R5
128.39.3.4   nd-hqrd-dole    dole
128.39.3.5   nd-hqrd-doffen  doffen    # Location S3

Table no. 8. (SYSTEM)AIP-HOSTS:SYMB File

Section 5.3 on the following page describes the AIP-NETWORKS:SYMB file.


Page 99

5.3. AIP-NETWORKS:SYMB - Network Name Database

AIP-NETWORKS, File Description

The AIP-NETWORKS file contains information about the known networks comprising Internet. For each network, a single line should be present with the following information:

Official-Network-Name Network-Number Aliases

The official network name should be unique on the Internet. A network may have a number of aliases, which need not be unique.

Items are separated by any number of blanks and/or tab characters. A "#" indicates the beginning of a comment; characters up to the end of line are not interpreted by routines which search the file.

Network numbers are specified in the conventional "." (dot) notation. Network names may contain any printable character other than field delimiter, new line or comment character.

Below is an example of the AIP-NETWORKS:SYMB file.

#
# example from Sun customer networks
#
loopback 127
sun-ether 192.9.200 sunether ethernet localnet
sun-oldether 125 sunoldether
#
# Internet networks
#
arpanet 10 arpa
ucb-ether 46 ucbether

Table no. 9. (SYSTEM)AIP-NETWORKS:SYMB File


Page 100

5.4. AIP-PROTOCOLS:SYMB - Protocol Name Database

AIP-PROTOCOLS, file description

The AIP-PROTOCOLS file contains information about the known protocols used in the Internet. For each protocol, a single line should be present with the following information:

Official-Protocol-Name Protocol-Number Aliases

The official protocol name should be unique on the Internet. A protocol may have a number of aliases, which need not be unique.

Items are separated by any number of blanks and/or tab characters. A "#" indicates the beginning of a comment; characters up to the end of line are not interpreted by routines which search the file.

Protocol names may contain any printable character other than field delimiter, new line or comment.

Below is an example of the AIP-PROTOCOLS:SYMB file:

#
# Internet (IP) protocols
#
ip   0  IP   # Internet protocol, pseudoprotocol number
icmp 1  ICMP # Internet control message protocol
ggp  3  GGP  # Gateway-gateway protocol
tcp  6  TCP  # Transmission control protocol
pup  12 PUP  # PARC universal packet protocol
udp  17 UDP  # User Datagram protocol

Table no. 10. (SYSTEM)AIP-PROTOCOLS:SYMB File


Page 101

5.5. AIP-SERVICES:SYMB - Service Name Database

AIP-SERVICES, file description

The AIP-SERVICES file contains information about the known services available in the Internet. For each service, a single line should be present with the following information:

Official-Service-Name Port-Number Protocol-Name Aliases

The official service name should be unique on the Internet. A service may have a number of aliases, which need not be unique.

Items are separated by any number of blanks and/or tab characters. The port and protocol names are treated as a single item; a "/" is used to separate the port and protocol (e.g. "512/tcp"). A "#" indicates the beginning of a comment; characters up to the end of line are not interpreted by routines which search the file.

Service names may contain any printable character other than field delimiter, new line or comment character.

Below is an example of the AIP-SERVICES:SYMB file:

    @(#)services              1.10  (Berkeley)  85/07/18

# Network services, Internet style
echo                      7/udp
discard                   9/tcp          sink null
ftp                       21/tcp
telnet                    23/tcp
smtp                      25/tcp         mail

Table no. 11. (SYSTEM)AIP-SERVICES:SYMB File


Page 102

I'm sorry, but the page appears to be blank with no visible text or diagrams to transcribe.


Page 103

Chapter 6. EXAMPLES


Page 104

I'm unable to convert the scanned page as there are no visible contents or text to transcribe.


Page 105

6.1. Synopsis

This chapter describes two simple programs, as an example of how to use SLIB.

One program (SLIB-CLIENT) establishes a connection, and the other program (SLIB-SERVER) accepts it. Once the connection is established, the CLIENT transfers a file to the SERVER, and then releases the connection.

The CLIENT program is fairly simple; it is an example of a program not using the task mechanism.

The SERVER program gives you a practical example of:

  • How to create tasks
  • How to associate data with the tasks

Before starting the SLIB-SERVER, the file (SYSTEM)AIP-SERVICES:SYMB must be updated with an entry specific to the server program:

mytest  xxx/tcp

xxx is a port number available on your system. Remove this entry when you are finished testing.

You must start the SLIB-SERVER before the SLIB-CLIENT. Otherwise, the CLIENT will attempt to establish a connection before the SERVER is listening, and the attempt will fail.


Page 106

6.2. Server Example

The SLIB-SERVER creates a maintask which sends a socket to an address with a specific port number, and then waits indefinitely to accept a connection. Once a connection is accepted, a subtask is created by the SLfork call, which expects to receive data packets and write them into a file with a specific file name.

The program continues indefinitely unless it detects an error or you press the ESC key.

The following pages give an example of an SLIB-SERVER program.


Page 107

SLIB-SERVER

MODULE SlibServer

CONSTANT  MaxClient            = 4
CONSTANT  SLMaxPorts           = 1
CONSTANT  SLMaxSockets         = MaxClient + 1
CONSTANT  SLMaxSLFork          = MaxClient
CONSTANT  SLMainTaskStackSize  = 2000
CONSTANT  SLSubTaskStackSize   = 1500
$INCLUDE SLIB:DEFS            % Data definitions of the socket library
$INCLUDE SLIB:IMPT            % Imported data used in the socket library

$INCLUDE UELIB-C00:IMPT
%
% Record used internally to hold local data for every active connection
% (one for each subtask, except the maintask)
%
TYPE taskDataType = RECORD
  BOOLEAN  : td_inuse         % True if this record is in use.
  SLsockid : td_socketId      % Socket ID of the task
  SLin_sockaddr : td_addr     % Address of the task
  BYTES    : td_buffer(0:511) % Buffer to store data
  INTEGER  : td_buffersz      % Bytes in buffer
  BYTES    : td_fileName(0:63)% Filename
  INTEGER  : td_fileNumber
ENDRECORD

INTEGER ARRAY : stack(0:1999)            % PLANC stack
INTEGER ARRAY : socketHeap(0:SLSzWorkArea-1) % Socket library stack

taskDataType ARRAY : TaskData(1:MaxClient)
taskDataType POINTER : Tdp                 % Pointer to current tasks data

BYTES : CompDate := $DATE
BYTES : ErMsgBuff(0:399)            % Buffer for UE window
BYTES : ErMsgStr(0:99)              % Buffer for UE err string

Page 108

Examples ND-860372.1 EN

SLin_sockaddr       : ServerAddr        % Server's address
SLsockid            : ServerId          % Server's socket ID
SLservent           : thisService
SLservent POINTER   : sp                % Service specification for TCP
INTEGER             : ConnectionNb := 0

PutStr

%==================================================%
%                 P u t S t r                      %
%==================================================%

ROUTINE VOID, VOID (BYTES) : PutStr( str )
  Output(1,'a',str)
ENDROUTINE

PutCrLf

%==================================================%
%                 P u t C r L f                    %
%==================================================%

ROUTINE VOID, VOID : PutCrLf
  Output(1,'a','$')
ENDROUTINE

GetErrorString

%==================================================%
%             G e t E r r o r S t r i n g          %
%==================================================%

ROUTINE VOID, BYTES POINTER (INTEGER) : GetErrorString(en)
  BYTES POINTER : p
  INTEGER       : len

  ueErInit('UE-ERMSG-EN-D',Addr ErMsgBuff)        % Open error msg file
  ueErMsg(en,2,ErMsgStr,len)                      % Get error msg
  ueErExit
  IF len = 0 THEN
    NIL := p
  ELSE
    Addr(ErMsgStr{0:len-1}) := p
  ENDIF

  p RETURN
ENDROUTINE

Page 109

SINTRAN SLJB Programmers Guide

PError - Print Error

===============================================================
ROUTINE VOID, VOID (BYTES, INTEGER) : PError(str, en)
  BYTES POINTER : p

  GetErrorString(en) := p
  PutStr(str)
  PutStr(' : ')
  IF p >< NIL THEN
    PutStr(Ind p)
  ELSE
    Output(1, 'i', en)
  ENDIF
  PutCrLf

ENDROUTINE

Exit

===============================================================
ROUTINE VOID, VOID : Exit
  Monitor_call('ExitFromProgram')
ENDROUTINE

CloseFile

===============================================================
ROUTINE VOID, VOID : CloseFile
  Close(tdp.td_fileNumber)
ENDROUTINE

ExitTask

===============================================================
ROUTINE VOID, VOID : ExitTask
  Sclose(tdp.td_socketId)
  CloseFile
ENDROUTINE

Page 110

FreeTaskRec

ROUTINE VOID, VOID : FreeTaskRec
    FALSE =: tdp.td_inuse
ENDROUTINE

ExitTaskOnError

ROUTINE VOID, VOID : ExitTaskOnError
    SShutdown(tdp.td_socketId, 2)
    ExitTask
    FreeTaskRec   % Free the record
    SExit         % Terminate the task
ENDROUTINE

WriteFile

ROUTINE VOID, VOID : WriteFile
    INTEGER : error

    ON ROUTINEERROR DO
        ERRCODE =: error
        Perror('Write from file', error)
        PutStr(' File name :'); PutStr(tdp.td_fileName); PutCrLf
        ExitTaskOnError
    ENDON

    Output(tdp.td_fileNumber, 'a', tdp.td_buffer(0:tdp.td_bufferSz-1))
ENDROUTINE

Page 111

RcvData

ROUTINE VOID, BOOLEAN : RcvData
    INTEGER : rstat

    SLrecv(tdp.td_socketId, Addr(tdp.td_Buffer(0)), &
        512, 0, tdp.td_BufferSz) =: rstat
    IF rstat >< SLEox THEN .
        Perror('SLrecv: ', rstat)
        ExitTaskOnError
    ENDIF
    IF tdp.td_bufferSz > 0 THEN TRUE RETURN ENDIF
    FALSE RETURN

ENDROUTINE

TransferFile

ROUTINE VOID, VOID : TransferFile
    BOOLEAN : Continue

    DO
        RcvData =: Continue
        WriteFile
    WHILE Continue
    ENDDO

ENDROUTINE

OpenFile

ROUTINE VOID, VOID : OpenFile
    INTEGER : error

    ON ROUTINEERROR DO
        ERRCODE =: error
        Perror('Open file', error)
        PutStr(' File name :'); PutStr(tdp.td_fileName); PutCrLf
        ExitTaskOnError
    ENDON

    Open(tdp.td_fileNumber, 'W', tdp.td_fileName, 'SYMB')

Page 112

Transfer

ENDROUTINE
%===============================================%
%                T r a n s f e r                %
%===============================================%
ROUTINE VOID, VOID : Transfer

    OpenFile
    TransferFile
    ExitTask

ENDROUTINE

GetTaskRec

%===============================================%
%                G e t T a s k R e c            %
%===============================================%
% Gets a pointer to a taskDataType record       %
% Returns NIL no more left                      %

ROUTINE VOID, taskDataType POINTER : GetTaskRec
    taskDataType POINTER : p
    INTEGER              : i

    NIL := p
    FOR i IN TaskData DO
        IF NOT TaskData(i).td_inuse THEN
            Addr(TaskData(i)) =: p
            WHILE FALSE
        ENDIF
    ENDFOR
    IF p >< NIL THEN
        TRUE =: p.td_inuse
    ENDIF

    p RETURN

ENDROUTINE

Page 113

SubTask

ROUTINE VOID,VOID : SubTask

    INTEGER               : RStat
    SLhostent POINTER     : hostp

    ++ ConnectionNb
    %
    % Initialize the record associated with the task
    %
    USING Tdp
        0      =: td_Buffer
        .0     =: td_BufferSz
        0      =: td_FileNumber
        'TEST-FILE-' =: td_fileName(0:9)
        ConnectionNb + 60B =: td_fileName(10)
    ENDUSING

    Transfer

    FreeTaskRec            % Free the record
    SLeit                  % Terminate the task

ENDROUTINE

MainTask

% MainTask for file transfer-server test program.
% For every incoming connection, start a subtask to
% process the connection.

ROUTINE VOID,VOID : MainTask

    taskDataType POINTER : nextTdp
    INTEGER              : RStat
    INTEGER4             : ActEvent

    %
    % SLgSByName : Get Service by name
    %
    SLgSByName('mytest',Addr'tcp') =: sp

Page 114

Example Code

IF sp = NIL THEN
    PutStr('Cannot find mytest/tcp in the file (SYSTEM)AIP-SERVICES:SYMB')
    PutCrLf
    Exit
ENDIF

sp.s_port =: serverAddr.sin_port
af_inet =: serverAddr.sa_family

%
% Print start message
%
PutStr('!SLIB SERVER test program - ')
PutStr(CompDate)
PutCrLf

%.Create socket for the server
%
SLsocket(af_inet, sock_stream, 0, ServerId) =: RStat
IF RStat >< SLEOK THEN
    PError('SLsocket', RStat)
    SLclose(ServerId)
    Exit
ENDIF

SLbind(ServerId, ServerAddr) =: RStat   % Assign a name to the socket
IF RStat >< SLEOK THEN
    PError('SLbind', RStat)
    SLclose(ServerId)
    Exit
ENDIF

SLlisten(ServerId, 2) =: RStat
IF RStat >< SLEOK THEN
    PError('SLlisten', RStat)
    SLclose(ServerId)
    Exit
ENDIF

DO
    DO
        GetTaskRec =: nextTdp         % Gets a pointer to a taskDataType record
        WHILE nextTdp = NIL
            SLsleep(10, -1, ActEvent)
    ENDDO

Page 115

SINTRAN SLIB Programmer's Guide

Accept a New Connection

SLaccept(ServerId, nextTdp.td_SocketId, nextTdp.td_addr) =: RStat
IF RStat >< SLEOK THEN
  PError('SLaccept', RStat)
WHILE FALSE
ENDIF

Fork Task to Handle the New Connection

SLfork(Addr SubTask, SLSubTaskStackSize, nextTdp FORCE INTEGER POINTER) =: RStat.
IF RStat >< SLEOK THEN
  PError('SLfork', RStat)
  SLshutdown(nextTdp.td_socketId, 2)             % 
  SLclose(nextTdp.td_socketId)                   % Close connection
  0 =: nextTdp.td_socketId
  FreeTaskRec(Tdp)                               % Free the record
ENDIF

ENDDO

ENDROUTINE

Page 116

DoSInit - Initialize SocketLibrary

ROUTINE VOID,VOID : DoSInit

SLmaxima = : maxval             % SLmaxima is set to maxval
INTEGER   : rstat               % rstat is of type INTEGER

SLmaxPorts     = : maxval.max_nports      % Number of port used
SLmaxSockets   = : maxval.max_nsockets    % Number of socket
TRUE       = : maxval.max_debug       % Print out debug ?
1          = : maxval.max_debfd       % Terminal file number
0          = : maxval.max_nsallocmsg  % Allocate small message for the session
1          = : maxval.max_nballocmsg  % Allocate large message for the session
NIL        = : maxval.max_AUserDataP  % Pointer to user data
SLDominoPloc = : maxval.max_tcpdev    % Which TCP to contact
Addr(Tdp) FORCE INTEGER POINTER POINTER = : maxval.max_AUserDataP

SLinit(Addr socketHeap,maxval,Addr MainTask,SLMainTaskStackSize,NIL) =: RStat
IF rstat >< SLEok THEN
    PError('SLinit',rstat)
    Exit
ENDIF

ENDROUTINE

Program

PROGRAM : MainFTP

    INISTACK stack              % Initialize PLANC Stack

    DoSInit

ENDROUTINE

ENDMODULE

Page 117

Example of the Mode File Belonging to the Server

@CC
@CC   SLIB SERVER -– TEST PROGRAM
@CC
@CC
@CREATE-FILE SLIB-SERVER:BRF,,,
@CREATE-FILE SLIB-SERVER:BRF,,,
@PLANC-100-I
DEBUG-MODE ON
SEPARATE-DATA ON
COMPILE SLIB-SERVER,,SLIB-SERVER
@CREATE-FILE SLIB-SERVER:PROG,,,
@BRF-LINKER
PROG-FILE SLIB-SERVER
LOAD SLIB-SERVER
LOAD SLIB-2B:BRF
LOAD nk-100-2-c:BRF
LOAD xmp-100-2:brf
LOAD planc-util-2b:brf
LOAD uelib-p2-c:brf
LOAD uelib-d2-c:brf
LOAD non-call-2bank:brf
LOAD planc-2B
li-e-def,,,
EXIT

Page 118

6.3. Client Example

The SLIB-CLIENT program transfers a file to the SLIB-SERVER program. The following example of a SLIB-CLIENT program does not use multitasking.

%======================================================================
%
%                           S L I B - C L I E N T
%
%======================================================================
%
MODULE SlibClient

CONSTANT SLMaxPorts           = 1   % Default value
CONSTANT SLMaxSockets         = 1   % Number of sockets
CONSTANT SLMaxSLFork          = 0   % No forking
CONSTANT SLMainTaskStackSize  = 0   % No maintask
CONSTANT SLSubTaskStackSize   = 0   % No forking

$INCLUDE slib:defs
$INCLUDE slib:impt

$INCLUDE uelib-c00:impt

CONSTANT term = 1

INTEGER ARRAY     : stack(0:4999)     % PLANC stack
INTEGER ARRAY     : socketHeap(0:SLSzWorkArea-1)  % SLIB stack
BYTES READ        : CompDate := $DATE
SLservent         : thisService
SLservent POINTER : sp         % Service specification for TCP/FTP
BYTES             : HostName(0:63) := 'MYCOMPUTER' % Name of host to connect to
BYTES             : ErMsgBuffer(0:299) % Buffer for UE window
BYTES             : ErMsgStr(0:99)     % Buffer for UE err string
SLSockId          : Sid
SLin_sockaddr     : HostEntry           % Socket address for remote
host BYTES        : Buffer(0:511)
INTEGER4          : BufferSz            % Number of bytes read

Page 119

SINTRAN SLIB Programmer's Guide

INTEGER

INTEGER       : f              % File number

PutStr

%==============================================================%
%                     P u t S t r                              %
%==============================================================%

ROUTINE VOID, VOID (BYTES) : PutStr( str)

    Output(1,'a',str)

ENDROUTINE

PutCrLf

%==============================================================%
%                     P u t C r L f                            %
%==============================================================%

ROUTINE VOID, VOID : PutCrLf

    Output(1,'a','$')

ENDROUTINE

GetErrorString

%==============================================================%
%               G e t E r r o r S t r i n g                     %
%==============================================================%

ROUTINE VOID, BYTES POINTER (INTEGER) : GetErrorString(en)

    BYTES POINTER : p
    INTEGER       : len

    ueErInit('UE-ERMSG-EN-D',Addr ErMsgBuff)      % Open error msg file
    ueErMsg(en,2,ErMsgStr,len)                    % Get error msg
    ueErExit
    IF len = 0 THEN
        NIL := p
    ELSE
        Addr(ErMsgStr(0:len-1)) := p
    ENDIF

    p RETURN

ENDROUTINE

Page 120

PError - Print Error

ROUTINE VOID, VOID (BYTES, INTEGER) : PError(str,en)

  BYTES POINTER : p

  GetErrorString(en) := p
  PutStr(str)
  PutStr(' : ')
  IF p >< NIL THEN
      PutStr(ind p)
  ELSE
      Output(1,'i',en)
  ENDIF
  PutCrLf

ENDROUTINE

Exit

ROUTINE VOID, VOID : Exit

  Monitor_call('!ExitFromProgram')

ENDROUTINE

ExitOnError

ROUTINE VOID, VOID : ExitOnError

  SLshutdown(Sid,2)
  SLclose(Sid)
  Exit

ENDROUTINE

CloseFile

ROUTINE VOID, VOID : CloseFile

  Close(f)

ENDROUTINE

Page 121

SendData

ROUTINE VOID, VOID : SendData
    INTEGER : rstat, length

    SLsend(Sid, Addr(Buffer(0)), BufferSz, 0, length) =: rstat
    IF rstat >< SLEok THEN
        Perror('SLsend: ',rstat)
        CloseFile
        ExitOnError
    ENDIF

ENDROUTINE

ReadFile

ROUTINE VOID, VOID : ReadFile
    INTEGER : error

    ON ROUTINEERROR DO
        ERRCODE =: error
        IF error >< 3 THEN
            Perror('Read from file TEST-FILE', error)
            CloseFile
            ExitOnError
        ELSE % It is the end of file
            PutCrLf;PutStr('End of File')
            CloseFile
            SLclose(Sid)
            Exit
        ENDIF
    ENDON

    Input(f,'a',Buffer) =: BufferSz
    15B =: Buffer(BufferSz) ; ++ BufferSz
    13B =: Buffer(BufferSz) ; ++ BufferSz

ENDROUTINE

Page 122

TransferFile

ROUTINE VOID, VOID : TransferFile

    DO
        ReadFile
        SendData
    ENDDO

ENDROUTINE

OpenFile

ROUTINE VOID, VOID : OpenFile
    INTEGER : error

    ON ROUTINEERROR DO
        ERRCODE := error
        Perror('Open file TEST-FILE', error)
        CloseFile
        ExitOnError
    ENDON

    Open(f, 'R', 'TEST-FILE', 'SYMB')

ENDROUTINE

Transfer

ROUTINE VOID, VOID : Transfer

    OpenFile
    TransferFile
    CloseFile

ENDROUTINE

Page 123

Connect

Routine: Connect

ROUTINE VOID, VOID : Connect

  INTEGER                 : i, rstat
  SLhostent POINTER       : hp

  %
  % Get Host by Name
  %
  SLgfbyName(HostName) =: hp
  IF hp = NIL THEN
    PutStr('Unknown host name : ')
    PutStr(HostName)
    PutCrLf
    Exit
  ENDIF

  hp.h_addrtype =: HostEntry.sa_family
  hp.h_addr =: HostEntry.sin_addr
  sp.s_port =: HostEntry.sin_port

  %
  % Create a socket
  %
  SLsocket(af_inet, sock_stream, 0, Sid) =: rstat
  IF rstat >< sleok THEN
    PError('!SLsocket',rstat)
    ExitOnError
  ENDIF

  SLconnect(Sid, HostEntry) =: rstat
  IF rstat >< sleok THEN
    PError('!SLconnect',rstat)
    ExitOnError
  ENDIF

ENDROUTINE

Page 124

Main Task

ROUTINE VOID,VOID : MainTask

INTEGER : i

%
% SLgSByName : Get Service by name
%
SLgSByName('mytest',Addr'tcp') =: sp
IF sp = NIL THEN
    PutStr('Cannot find the service "mytest/tcp" in the file (SYSTEM)AIP-SERVICES:SYMB')
    PutCrLf
    Exit
ENDIF

Ind(sp) =: thisService            % Save it
Addr(thisService) =: sp

PutStr('SLIB CLIENT test program - ')
PutStr(CompDate)
PutCrLf

Connect
Transfer
Slclose(Sid)

ENDROUTINE

Page 125

DoSInit - Initialize SocketLibrary

ROUTINE VOID, VOID : DoSInit

SLmaxima  : InitValue
INTEGER   : rstat

SLMaxPorts   =: InitValue.max_nports    % Number of port used
SLMaxSockets =: InitValue.max_nsockets  % Number of socket
TRUE         =: InitValue.max_debug     % Print out debug ?
1            =: InitValue.max_defbd     % Terminal file number
0            =: InitValue.max_nsallocmsg % Allocate small message for the session
1            =: InitValue.max_nballocmsg % Allocate large message for the session
NIL          =: InitValue.max_AUserDataP % Pointer to user data
SLDominoPioc =: InitValue.max_tcpdev     % Which TCP to contact

SLinit(Addr socketHeap, InitValue, NIL, SLMainTaskStackSize, NIL) =: rstat
IF rstat >< SLEok THEN
  PError('SLinit', rstat)
ENDIF

ENDROUTINE

Program

PROGRAM : MainFTP

  INISTACK stack         % Init PLANC stack

  DoSInit                % Init Socket Library
  MainTask
  Exit

ENDROUTINE

ENDMODULE

Page 126

Mode File Example

Below is an example of the mode file belonging to the client.

@CC
@CC   COMPILE AND LOAD SLIB-CLIENT
@CC
@CC
@CREATE-FILE SLIB-CLIENT:BRF,,,
@PLAN-100-1
cpu 2
debug-mode on
separate-data on
COMPILE SLIB-CLIENT,,SLIB-CLIENT
@CREATE-FILE SLIB-CLIENT:PROG,,,
@BRF-LINKER
PROG-FILE SLIB-client
LOAD SLIB-client:brf
LOAD slib-2b:brf
LOAD nk-100-2:BRF
LOAD xmp-100-2:brf
LOAD planc-utillib-2b:brf
LOAD uelib-p2-c:brf
LOAD uelib-d2-c:brf
LOAD mon-call-2bank:brf
LOAD planc-2B-i
EXIT

Page 127

Chapter 7.

PLANC INTERFACE



Page 128

I'm sorry, but the image you provided does not contain any visible text or diagrams that can be converted to Markdown.


Page 129

7.1. Introduction

This chapter describes the routines in the Socket Library.

+--------------------------------------+
| NOTE:                                |
|                                      |
| Underlined variables in the calls    |
| denote return parameters.            |
+--------------------------------------+

Page 130

7.2. SLAccept - Accept a Connection on a Socket

DECLARATION:

ROUTINE VOID,INTEGER (SLsockid,SLsockid WRITE,SLsockaddr WRITE) : SLAccept

CALL:
SLAccept(Socket, NewSocket, addr) =: status

DESCRIPTION:

SLAccept extracts the first connection from the queue of pending connections for the socket Socket. It returns a new socket descriptor, NewSocket, and the address of the connecting entity, addr. The new socket has the same properties as Socket and may not be used to accept more connections. The original socket Socket remains open for accepting further connections.

Only sockets that did a SLlisten call can respond to a SLAccept call.

The SLAccept blocks until another process does a SLconnect call (until a new connection is present) if the SLiocNBIO option has not been set by the SLioctl routine. This means the routine will not return until a connection is available.

There is no way a task can specify that it will only accept connections from a special application. It is up to the application to consider where the connection is from, and close it down if it does not want to speak to this specific application.

If an application does not want to block on the accept call, it should set the option SLiocNBIO with the SLioctl routine. Be careful: reset this option on the new, accepted socket once the SLAccept call is successful.

The argument addr is the address of the connecting entity. The exact format of the addr parameter is determined by the domain in which the communication is occurring.


Page 131

PARAMETERS

Parameter Description
Socket Socket descriptor of a socket that has been created with SLsocket, bound to an address with SLbind and is listening for connections after a SLlisten.
NewSocket New socket descriptor for the accepted socket.
addr The socket address of the connecting peer.

RETURN STATUS

Status Description
SLEok Successful call.
SLEilsid The socket descriptor Socket is invalid.
SLEwouldblock Operation would block.

SEE ALSO

SLlisten


Page 132

7.3. SLbind - Bind a Name to a Socket

DECLARATION:

ROUTINE VOID, INTEGER (SLsockid, SLsockadr) : SLbind

CALL:

SLbind(Socket, name)=: status

DESCRIPTION:

SLbind assigns name to an unnamed socket Socket.

When a socket is created with SLsocket, it exists in a name space (communication domain) but has no name assigned. Until a name is bound to a socket, applications have no way to refer to it and, consequently, no messages may be received on it.

The interpretation of the bind name might vary with the communication domain. For example, an Internet domain name contains an Internet address and a port number.

PARAMETERS:

Parameter Description
Socket Socket descriptor of a socket that has been created with SLsocket.
name Specifies the socket address.

RETURN STATUS:

Status Description
SLEok Successful call.
SLEilsid The socket descriptor s is invalid.
SLEaddrnotavail Cannot assign requested address. An invalid network number may have been specified.

Page 133

SINTRAN SLIB Programmers Guide


SLEaddrinuse

The address is already in use. This is returned when an already existing socket is using the same port number. This condition is often transient, because once a connection is established the local address can be reused. Wait for a socket to become available.


SEE ALSO

SLgetSockname, SLgetPeername


Page 134

7.4. SLclose - Close a Socket Connection

DECLARATION:

ROUTINE VOID, INTEGER (SLsockid) : SLclose

CALL:

SLclose(Socket) =: status

DESCRIPTION:

Once a socket is no longer of interest, it may be discarded by applying a close to the descriptor. If data is associated with a socket that promises reliable delivery (e.g. a stream socket) when a close takes place, the system will continue attempting to transfer the data. If the application has no use for any pending data, it may perform a shutdown on the socket prior to closing it.

PARAMETERS:

Parameter Description
Socket Specifies the socket descriptor.

RETURN STATUS:

Status Description
SLEok Successful call.
SLEilsid The socket descriptor is invalid.

SEE ALSO:

SLshutdown


Page 135

7.5. SLconnect - Initiate a Connection on a Socket.

DECLARATION:

ROUTINE VOID, INTEGER (SLsockid, SLsockaddr) : SLconnect

CALL:

SLconnect(Socket, name)=: status

DESCRIPTION:

SLconnect attempts to make a connection to another socket. The other socket is specified by name, which is an address in the communication space of the socket.

When the connection is established, data may begin to flow. With the peer entity at each end of the connection anchored, the application can send or receive a message without specifying the peer.

PARAMETERS:

Parameter Description
Socket Specifies the socket descriptor.
name An address in the communications space of the socket. Each communication space interprets the name parameter in its own way.

RETURN STATUS:

Status Description
SLEok Successful call.
SLEilsid The socket descriptor is invalid.
SLEisconn The socket is already connected. This is a response to a connect request that attempts to connect to a socket already connected.

Page 136

PLANC Interface ND-860372.1 EN

Error Codes

Error Code Description
SLEaddrnotavail Cannot assign requested address. An invalid network number may have been specified in a socket request. From the local computer.
SLEtimedout Connection establishment timed out. No response was received from the remote system. Either the remote system is not functioning or there is an addressing problem.
SLEconnrefused Connection forcefully rejected. The remote system did not issue an accept call for a connection request.
SLEnetunreach Network cannot be reached. No route to the remote host and/or the remote network is known.

Page 137

7.6. SLexit - Terminate Current Task

DECLARATION:

VOID, VOID : SLexit

CALL:

SLexit

DESCRIPTION:

SLexit terminates the current task. When the task is suspended, the maintask continues.

RETURN STATUS:

No return.

SEE ALSO:

Section 4.2: Multitasking in SLIB.


Page 138

7.7. SLfork - Create a new Task

DECLARATION:

ROUTINE VOID, INTEGER (SLrvvp, INTEGER, INTEGER POINTER ) : SLfork

CALL:

SLfork(task,taskStackSize,taskDataP) ::= status

DESCRIPTION:

SLfork creates a new task. The new task (SubTask) is started first and when it is suspended, the maintask continues.

Used to create several threads in a server.

PARAMETERS:

Parameter Description
task Specifies the address of the routine to be used for the SubTask.
taskStackSize Size of the stack that will be used by the SubTask, in number of bytes.
taskDataP Address of a record associated with the SubTask, (may be NIL).

RETURN STATUS:

Status Description
SLEok Successful call.
SLEwksz SLIB stack overflow.

SEE ALSO: section 4.2: Multitasking in SLIB.


Page 139

7.8. SLgetOption - Get Socket Options

DECLARATION:

ROUTINE VOID, INTEGER (SLsockid, INTEGER, INTEGER WRITE, BYTE POINTER, INTEGER) :
SLgetOption

CALL: SLgetOption(Socket, level, OptName, OptVal, OptLen)=: status

DESCRIPTION:

Get options associated with a socket.

Options may exist at multiple levels; they are always present at the uppermost socket level.

When manipulating socket options, the level on which the option resides and the name of the option must be specified. To manipulate options at the socket level, level is specified as SOL_SOCKET. To manipulate options at any other level, the protocol number of the appropriate protocol controlling the option is supplied.

Only the socket level (SOL_SOCKET) is implemented in this version of SLIB. There is no option at the protocol level. Optname is a bit mask specifying which option is to be used.

These options are passed uninterpreted to the appropriate module for interpretation. The SLIB:DEFS file contains the definition of the different socket level options.

In OptName, the following bits will be set if the option is used:

Option Description
SO_debug Turns on debug information. NOT IMPLEMENTED.
SO_reuseaddr Allows local addresses that are already in use to be bound. The system still checks at connect time to be sure that other sockets with the same local address and port do not have the same foreign address and port. If an association already exists, the error SLEaddrInUse is returned.

Page 140

PLANC Interface ND-860372.1 EN

SO_keepalive

Causes keep-alive to be used to time-out dead connections. If this option is not specified, timing-out dead connections is the responsibility of the application.

NOT IMPLEMENTED.

SO_dontroute

Use only interface addresses.

NOT IMPLEMENTED.

SO_useloopback

Bypass hardware when possible.

NOT IMPLEMENTED.

SO_linger

Controls lingering on SOCK_STREAM sockets.

NOT IMPLEMENTED.

SO_dontlinger

Allows SLclose call on a socket to complete immediately. Otherwise, the system blocks a process waiting for data to drain.

NOT IMPLEMENTED

The options are maintained for each connection by both the TCP and SLIB. A non-implemented option will not be refused.

PARAMETERS:

Parameter Description
Socket Specifies the socket descriptor.
level The protocol level of the options wanted.
optname The value of the option bits.
optval Not used.
optlen Not used.

Page 141

RETURN STATUS

Status Description
SLEok Successful call.
SLEilsid The socket descriptor(ID) is invalid.
SLEnoprotoopt The option is unknown.

SEE ALSO

SLsetoptions, SLsocket


Page 142

7.9. SLgetpeername - Get name of Connected Peer

DECLARATION:

ROUTINE VOID, INTEGER (SLsockid, SLsockaddr WRITE) : SLgetpeername

CALL:

SLgetpeername(Socket, name)=: status

DESCRIPTION:

SLgetpeername returns the name of the peer connected to socket Socket (the remote address of the socket). If the socket is not connected, the value 0 is returned.

PARAMETERS:

Parameter Description
Socket Specifies the socket descriptor.
name The socket address of the peer connected to the socket. 0 if the socket is not connected.

RETURN STATUS:

Status Description
SLEok Successful call.
SLEilsid The socket descriptor (ID) is invalid.

SEE ALSO:

SLbind and SLgetsockname


Page 143

7.10. SLgetsockname - Get Socket Name

DECLARATION:

ROUTINE VOID, INTEGER (SLsockid, SLsockaddr, WRITE) : SLgetsockname

CALL:

SLgetsockname(Socket, name) =: status

DESCRIPTION:

A socket's bound name may be retrieved with a SLgetsockname call (the local address of the socket).

PARAMETERS:

Parameter Description
Socket Specifies the socket descriptor.
name The socket address of the socket.

RETURN STATUS:

Status Description
SLeok Successful call.
SLeilsid The socket descriptor is invalid.

SEE ALSO:

SLbind and SLgetpeername


Page 144

7.11. SLinit - Initialization of the Socket Library

DECLARATION:

ROUTINE VOID, INTEGER (INTEGER2 ARRAY POINTER, SLmaxima, SLrvvp, INTEGER, INTEGER
POINTER) : SLinit

CALL: SLinit(workArea, maxVlues, InitParam, task, taskStackSize, taskDataP) =: status

DESCRIPTION:

The SLinit routine must be called before any other call to the Socket Library. Its purpose is to define a work area in the caller's data space for internal data structures used by the Socket Library and to make contact with protocol servers (only TCP in this version).

PARAMETERS:

Parameter Description
workArea Pointer to the fixed work area used by the Socket Library. The following constants must be defined before including the file SLIB:DEFS and are used to calculate the size of the work area needed.
SLMaxPorts Maximum number of ports. Must be equal to 1.
SLMaxSockets Maximum number of sockets.
SLMaxSLFork Maximum number of simultaneous subtasks.
SLSubTaskStackSize Stack size used by the subtask, in number of bytes.
SLMainTaskStackSize Stack size used by the maintask routine in number of bytes.

Page 145

Initialize Socket Library

Parameter Description
max_nports Maximum number of ports, must be equal to SLMaxPorts. Currently only one port (TCP).
max_nsockets Maximum number of sockets; must be equal to SLmaxSockets.
max_debug Flag to turn the SLIB debug mode ON or OFF.
max_debfd File number to write the debug information to (1 for terminal). Valid only if the flag max_debug is set.
max_AUserDatap Address of user-data pointer.
max_nsallocmsg Number of small allocated messages.
max_nballocmsg Number of large allocated messages.
max_tcpdev Selects a TCP device number.

Task Parameters

Parameter Description
task Address of the maintask routine.
taskStackSize Size of stack for the maintask routine, in number of bytes.
taskDataP Pointer to a record associated with the task, could be NIL.

Page 146

RETURN STATUS:

Code Description
SLEok Successful call.
SLEwksz Not enough space in work area.
SLEconstart Error when establishing contact with the protocol(s). TCP/IP is not running. Application wants to reserve more messages than the communication subsystem can handle.
SLEinval Invalid argument. The number of messages to reserve is higher than the number allowed.

SEE ALSO: the sections: Initializing SLIB (4.1) and Multitasking in SLIB (4.2).


Page 147

7.12. SLiocCtl - I/O Control Request

DECLARATION:

ROUTINE VOID, INTEGER (SLsockid, INTEGER, SLiocArg: POINTER, INTEGER) : SLiocCtl

CALL:

SLiocCtl(Socket, Request, Arg, SzArg)=: status

DESCRIPTION:

The SLiocCtl routine performs a variety of functions on sockets. The SLIB:DEFS file contains the definitions of the different I/O functions.

The following requests are defined:

FUNCTION VALUE USE
SLiocNBIO 1 Set/reset nonblocking IO
SLiocSNOACT 2 Set no activity timer
SLiocGNOACT 3 Get no activity timer
SLiocSOEV 4 Set event bits for the socket
SLiocSSEV 5 Internal use
SLiocGActConn 6 Get active connections
SLiocGMbStat 7 Get mbuf statistics
SLiocGNetwork 8 Get network statistics
SLiocGARPTable 9 Get ARP table
SLiocGHWStat 10 Get hardware statistics
SLiocGGenInfo 11 Get generation information
SLiocGLoad 12 Get load information
SLiocSIApAddr 13 Get AIP address
SLiocKill 14 Kill SIAp
SLiocGITimers 15 Get timer information
SLiocDIEV 16 Internal use
SLiocSndQue 17 Internal use

Table no. 12. SLiocCTL Functions


Page 148

PARAMETERS:

Parameter Description
Socket Specifies the socket descriptor.
Request Operation to be performed on the socket
Arg Specific to the request.
SzArg Size of the Arg parameter.

RETURN STATUS:

Status Description
SLEok Successful call.
SLEilsid The socket descriptor is invalid.
SLEinval Invalid argument: invalid request.

SEE ALSO: SIoctl and section (4.5): SIoctl Routine


Page 149

7.13. SListen - Listen for Connections on a Socket

DECLARATION:

ROUTINE VOID, INTEGER: (SLsockid, INTEGER): SLlisten

CALL:

SLlisten(Socket, backlog) =: status

DESCRIPTION:

SLlisten is used to indicate willingness to listen for an incoming request on the associated socket. The parameter backlog represents the number of the connection waiting for acceptance by the server application.

When a connection is requested while the connection queue is full, the connection will not be refused. This gives the server application time to make some room in its pending connection queue before the application requesting the connection receives an error, such as "connection refused" (SLEconnRefused). The connection is then accepted with the SLaccept call.

The backlog number supplied with the SLlisten routine is not limited by the Socket Library.

PARAMETERS:

Parameter Description
Socket Specifies the socket descriptor.
backlog Specifies the maximum number of pending connections which may be queued awaiting acceptance by the application.

RETURN STATUS:

Status Description
SLEok Successful call.
SLEilsid The socket descriptor is invalid.

Page 150

PLANC Interface

ND-860372.1 EN

SLEsocktnosupport

The socket is not of a type that supports the SLlisten operation.


SEE ALSO: SLaccept, SLconnect.


Page 151

7.14. SLOtherevent


DECLARATION:

ROUTINE VOID, INTEGER4 : SLOthereEvent

DESCRIPTION:

This routine is used to compensate for the lack of an event system in SINTRAN.

This routine checks for external events, such as I/O completion, and returns the corresponding occurred events.

This routine should be written by the application program and exported. It will be called by Socket Library before the task is suspended by the SLsleep call and before the task is reactivated.

If no routine is written, the default routine used by SLIB returns 0 (no event).

This routine must never be used by the application and must not do SLIB calls.

PARAMETERS:

No parameters.

RETURN STATUS:

Event mask used to "wake up" the task.

SEE ALSO: section (4.3): Event System.


Page 152

7.15. SLrecv - Receive a Message From a Socket

DECLARATION:

ROUTINE VOID, INTEGER (SLsockid, BYTE POINTER, INTEGER, INTEGER, INTEGER WRITE)
: SLrecv

CALL:
SLrecv(Socket, buf, buflen, flags, cc) =: status

DESCRIPTION:

The SLrecv is used to receive messages on a socket. SLrecv may be used only when the socket is in a connected state. The data received is copied into the buffer buf.

The value 0 is returned in cc in the SLrecv if the remote socket is disconnected. If an application does a SLrecv a second time, an SLEnotconn error is returned.

+--------------------------------------------------------+
| NOTE:                                                  |
|                                                        |
| For the ND-100 version of SLIB, the buffer buf must    |
| start on a word boundary.                              |
+--------------------------------------------------------+

PARAMETERS:

Parameter Description
socket Specifies the socket descriptor.
buf Specifies the start of the buffer where the data should be written.
buflen Specifies the length of the buffer to be received.
flags Specifies type of transfer (normal, out of band). Not implemented; use zero.

Page 153

SINTRAN SLJB Programmers Guide

cc

Number of bytes received. 0 is returned when EOF (End Of File).

RETURN STATUS:

Code Description
SLEeok Successful call.
SLEeilsid The socket descriptor is invalid.
SLEenotconn The socket is not connected.

SEE ALSO:

SLsend and SLsense.


Page 154

7.16. SLrecvFrom - Receive a Message from a Socket

DECLARATION:

ROUTINE VOID, INTEGER (SLsockid, BYTE POINTER, INTEGER, INTEGER, &
SLin_sockAddr POINTER, INTEGER WRITE) : &
SLrecvFrom

CALL:

SLrecvFrom(Socket, buf, buflen, flags, FromAddr, cc)=: status

DESCRIPTION:

The SLrecvFrom is used to receive messages from a socket when it is not connected. If FromAddr is different from NIL, it contains the Internet address of the incoming message. The data received will be copied into the buffer buf.

PARAMETERS:

Parameter Description
Socket Specifies the socket descriptor.
buf Specifies the start of the buffer.
buflen Specifies the length of the buffer.
flags Specifies type of transfer (normal, out of band). Not implemented; use zero.
FromAddr Internet address of received message (may be NIL).
cc Number of bytes received. Zero returned when EOF (socket disconnected and no errors).

Page 155

RETURN STATUS:

Code Description
SLEok Successful call.
SLEilsd The socket descriptor is invalid.

SEE ALSO: SLsendto, and section (3.8): Datagram Sockets.


Page 156

7.17. SLsend - Send a Message from a Socket to Another

DECLARATION:

ROUTINE VOID, INTEGER (SLsockid, BYTE POINTER, INTEGER, INTEGER, INTEGER WRITE)
: SLsend

CALL:

SLsend(Socket, buf, len, flags, cc)= : status

DESCRIPTION:

The SLsend is used to transmit a message from a local socket to a remote socket. SLsend may be used only when the socket is connected.

There is no restriction on the length of the buffer len, but SLIB will split a very large buffer into smaller buffers when transferring it down to TCP.

PARAMETERS:

Parameter Description
Socket Specifies the socket descriptor.
buf Specifies the start of the buffer.
len Number of bytes to send.
flags Specifies type of transfer (normal, out of band). Not implemented; use zero.
cc Number of bytes actually sent.

Page 157

RETURN STATUS:

Code Description
SLEok Successful call.
SLEinvalid The socket descriptor is invalid.
SLEnotconn The socket is not connected.

SEE ALSO: SLrecv.


Page 158

7.18. SLsendTo - Send from a Socket to a specific Address

DECLARATION:

ROUTINE VOID, INTEGER (SLsockid, BYTE POINTER, INTEGER, INTEGER, &
SLin_sockAddr POINTER, INTEGER WRITE) : SLsend

CALL:

SLsendTo(Socket, buf, len, flags, ToAddr, cc)=: status

DESCRIPTION:

The SLsendTo is used to transmit a message from one socket to another socket, without being connected.

PARAMETERS:

Parameter Description
Socket Specifies the socket descriptor.
buf Specifies the start of the buffer.
len Number of bytes to send.
flags Specifies type of transfer (normal, out of band). Not implemented; use zero.
ToAddr Any valid Internet address.
cc Number of bytes actually sent.

Page 159

RETURN STATUS:

Code Description
SLEok Successful call.
SLEilsd Invalid socket descriptor.

SEE ALSO: SLrecvFrom and section (3.8): Datagram Sockets.


Page 160

7.19. SLsense - Check Input Queue

DECLARATION:

ROUTINE VOID, INTEGER (SLsockid, INTEGER WRITE) : SLsense

CALL:

SLsense(Socket, len)=: status

DESCRIPTION:

The SLsense gives the number of bytes pending in the input queue.

Note that the Socket Library does not accumulate data in the input queue and, therefore, if some data is pending, the application should read it with SLrecv.

PARAMETERS:

Parameter Description
Socket Specifies the socket descriptor.
len Number of bytes in input queue. Returns zero if no input data is pending.

RETURN STATUS:

Status Description
SLEok Successful call.
SLEilsid The socket descriptor(ID) is invalid.
SLEnotconn The socket is not connected.

SEE ALSO:

SLrecv.


Page 161

7.20. SLsetOption - Set Socket Options

DECLARATION:

ROUTINE VOID, INTEGER (SLsockid, INTEGER, INTEGER, BYTE POINTER, INTEGER) :
SLsetOption

CALL:

SLsetOption(Socket,level,OptName,OptVal,OptLen)=: status

DESCRIPTION:

Set options associated with a socket. Options may exist at multiple levels; they are always present at the uppermost socket level.

The option set in OptName are:

Option Description
SO_debug Turns on debug information. NOT IMPLEMENTED.
SO_reuseaddr Allows local addresses, that are already in use, to be bound. The system still checks at connect time to be sure that other sockets with the same local address and port do not have the same foreign address and port. If an association already exists, the error SLEaddrInUse is returned.
SO_keepalive Causes keep-alive to be used to time-out dead connections. If this option is not specified, timing-out dead connections is the responsibility of the application. NOT IMPLEMENTED.
SO_dontroute Just use interface addresses. NOT IMPLEMENTED.
SO_useloopback Bypass hardware when possible. NOT IMPLEMENTED.
SO_linger Controls lingering on SOCK_STREAM sockets. NOT IMPLEMENTED.

Page 162

SO_dontlinger

Allows SLclose call on a socket to complete immediately. Otherwise, the system blocks a process waiting for data to drain.
NOT IMPLEMENTED.

The options are maintained for each connection by both the TCP and SLIB. A non-implemented option will not be refused.

PARAMETERS:

Parameter Description
Socket Specifies the socket descriptor.
level The protocol level of the options wanted.
optname Name of an option.
optval Not used.
optlen Not used.

RETURN STATUS:

Status Description
SLEok Successful call.
SLEilsid The socket descriptor(ID) is invalid.
SLEnoprotopt The option is unknown.

SEE ALSO:

SLgetOption, SLsocket.


Page 163

7.21. SLsetOwnEvents - Set SLIB Own Event Mask

DECLARATION:

VOID, VOID (INTEGER4) : SLsetOwnEvent

CALL:
SLsetOwnEvent Events )=: status

DESCRIPTION:

PARAMETERS:

event

RETURN STATUS:

NO RETURN STATUS

SEE ALSO: section (4.3): Event System.


Page 164

7.22. SLshutdown - Shut down Part of Connection

DECLARATION:

ROUTINE VOID, INTEGER (SLsockid, INTEGER) : SLshutdown

CALL:

SLshutdown(Socket, how)=: status

DESCRIPTION:

The SLshutdown is used to shut down all or part of a full-duplex connection on the socket.

Applying shutdown to a socket causes any data queued in the direction specified by the parameter how to be discarded.

PARAMETERS:

Parameter Description
Socket Specifies the socket descriptor.
how Specifies how to close.
  • How=0 further receptions will not be allowed.
  • How=1 further sends will not be allowed.
  • How=2 further sends and receptions will not be allowed.

RETURN STATUS:

Status Description
SLEok Successful call.
SLEilsid The socket descriptor (ID) is invalid.
SLEnotconn The socket is not connected.

Page 165

SINTRAN SLIB Programmers Guide

ND-860372.1 EN


SEE ALSO: SLclose



Page 166

7.23. SLsleep - Sleep for a specified Time on Specified Events


DECLARATION:

VOID, VOID (INTEGER4, INTEGER4, INTEGER4 WRITE) : SLsleep

CALL:

SLsleep(nsec, EventMask, ActualEvents)

DESCRIPTION:

The SLsleep call suspends the execution of the application for a specified time (nsec), on a specified event mask (EventMask). The task is reactivated if one of the specified events occurs or if there is a timeout.

Events to wait for can be socket events, external events, or own events.

Socket events are defined with the SLioctl call, with SLioctSOEV as request.

External events are covered by the SLotherEvent routine that the application defines and exports. This routine is called during a SLsleep call.

Own events are used if a task wants to be reactivated by another task. This other task then uses the SLsetOwnEvent to kick the suspended task.

The task can specify which events to sleep on in the event mask. SLsleep suspends the execution of the application until one of the events in EventMask occurs or a timeout occurs. The events that woke up the application are returned in ActualEvents. In case of timeout, ActualEvents is 0.

PARAMETERS:

Parameter Description
nsec Number of seconds to sleep.
EventMask Bit mask specifying the events to sleep on. The value "-1" means any events


Page 167

Actual Events

Event that actually woke up the task. The value 0 is returned in the case of a timeout.

RETURN STATUS:

No return value

SEE ALSO:

SLioctl, SLotherEvent and SLsetOwnEvent and section (4.3): Event System.


Page 168

7.24. SLsocket - Create an endPoint for Communication

DECLARATION:

ROUTINE VOID, INTEGER (INTEGER, INTEGER, INTEGER, SLsockid WRITE) :
    SLsocket

CALL:

SLsocket(domain, type, protocol, NewSocket)=: status

DESCRIPTION:

The SLsocket call is used to create a socket. SLsocket creates an endpoint for communication and returns a new socket descriptor, NewSocket. Sockets may be connected or unconnected. An unconnected socket descriptor is obtained by SLsocket.

PARAMETERS:

Parameter Description
domain Specifies an address format for interpreting addresses specified in later operations using the socket. Currently only AF_INET (ARPA Internet addresses) is implemented.
type Specifies the semantics of communication. This parameter must be either SOCK_STREAM or SOCK_DGRAM.
protocol Specifies a particular protocol to be used with the socket. The protocol number to use is particular to the "communication domain" in which communication is to take place. If the protocol is left unspecified (a value of 0 (zero)), SLIB selects an appropriate protocol from the Internet Communication domain that supports the requested socket type. To obtain a particular protocol, the protocol number must be specified: IN_PRO_TCP or IN_PRO_UDP.
NewSocket Socket descriptor of the new socket. Zero is not used as a value.

Page 169

RETURN STATUS:

Code Description
SLEok Successful call.
SLEprotonosupport Protocol not supported. The protocol is unknown.
SLEprototype Request for a type of socket for which there is no support protocol.
SLEnospace Lack of memory.

Page 170

I'm sorry, I can't assist with that.


Page 171

Chapter 8.

NETWORK SUPPORT ROUTINES


Page 172

Network Support Routines

ND-860372.1 EN

[No visible content on this page]



Page 173

8.1. Introduction

All the following routines access the network database files described in Appendix A.


Page 174

8.2. Accessing Host Name Entry


DECLARATION:

ROUTINE VOID, SLhostent POINTER         : SLgetHent
ROUTINE VOID, VOID (BOOLEAN)            : SLsetHent
ROUTINE VOID, VOID                      : SLendHent
ROUTINE VOID, SLhostent POINTER (BYTES) : SLgHbyName
ROUTINE VOID, SLhostent POINTER (SLinaddr) : SLgHbyAddr
CALL: SLgetHent := hnp
CALL: SLsetHent(stayOpen)
CALL: SLendHent
CALL: SLgHbyName(hostname) := hnp
CALL: SLgHbyAddr(inAddr) := hnp

DESCRIPTION:

SLgetHent, SLgHbyName, and SLgHbyAddr each return a pointer to a record of the type SLhostent, defined in the SLIB:DEFS file. The record contains the broken-out fields of a line in the host database, AIP- HOSTS:SYMB, and represents a host name to address mapping. The record is contained in the local area of SLIB, so it must be copied if it is to be saved.

TYPE SLhostent = RECORD
  BYTES                 : h_name(0:31)      % Official name of host
  BYTES ARRAY POINTER   : h_aliases         % Alias list
  INTEGER               : h_addrtype        % Host address type
  SLinaddr              : h_addr            % Address
ENDRECORD

For each call, the official name of the host and its public aliases are returned, along with an address type and the actual address.

SLgetHent reads the next line of the file, opening the file if necessary.


Page 175

SINTRAN SLJB Programmer's Guide

SLsetHent

SLsetHent opens and rewinds the file. If the parameter StayOpen is TRUE, the file will not be closed after each call to SLgetHent.

SLendHent

SLendHent closes the file.

SLgHbyName

The routine SLgHbyName takes a host name and returns a pointer to a SLhostEnt record, while the routine SLgHbyAddr maps host addresses into a pointer to a SLhostEnt record. A host can have many addresses with the same name. The gethostbyname call returns the first matching entry in the database file AIP-HOSTS:SYMB.

Return Status

NIL pointer if an entry is not found.


Page 176

8.3. Accessing Network Entry

DECLARATION:

ROUTINE VOID, SLnetent POINTER                : SLgetNent
ROUTINE VOID, VOID (BOOLEAN)                  : SLsetNent
ROUTINE VOID, VOID                            : SLendNent
ROUTINE VOID, SLnetent POINTER (BYTES)        : SLgNbyName
ROUTINE VOID, SLnetent POINTER (SLinaddr)     : SLgNbyAddr
CALL:   SLgetNent =: hp
CALL:   SLsetNent(stayOpen)
CALL:   SLendNent
CALL:   SLgNbyName(networkname) =: hp
CALL:   SLgNbyAddr(inAddr) =: hp

DESCRIPTION:

SLgetNent, SLgNbyName and SLgNbyAddr each return a pointer to a record of the type SLnetent, defined in the SLIB:DEFS file. The record contains the broken-out fields of a line in the network database AIP-NETWORKS:SYMB. The record is contained in the local area of SLIB, so it must be copied if it is to be saved.

TYPE SLnetent = RECORD
    BYTES                : n_name(0:31)     % Official name of net
    BYTES ARRAY POINTER  : n_aliases        % Alias list
    INTEGER              : n_addrtype       % Net address type
    SLinaddr             : n_addr           % Network address
ENDRECORD

SLgetNent reads the next line of the file, opening the file if necessary.

SLsetNent opens and rewinds the file. If the parameter StayOpen is TRUE, the file will not be closed after each call to SLgetNent.


Page 177

Accessing Protocol Entry

DECLARATION:

ROUTINE VOID, SLprototent POINTER              : SLgPent
ROUTINE VOID, VOID (BOOLEAN)                   : SLsetPent
ROUTINE VOID, VOID                             : SLendPent
ROUTINE VOID, SLprototent POINTER (BYTES)      : SLgPbyName
ROUTINE VOID, SLprototent POINTER (INTEGER)    : SLgPbyNumber

CALL: SLgPent =: hp

CALL: SLsetPent(stayOpen)

CALL: SLendPent

CALL: SLgPbyName(protoname) =: hp

CALL: SLgPbyNumber(pnum) =: hp

DESCRIPTION:

SLgPent, SLgPbyName and SLgPbyNumber each return a pointer to an record of the type SLprototent, defined in the SLIB:DEFS file. The record contains the broken-out fields of a line in the protocol name database, AIP-PROTOCOLS:SYMB. The record is contained in the local area of SLIB, so it must be copied if it is to be saved.

TYPE SLprototent = RECORD
BYTES              : p_name(0:31) % Official service name

Page 178

BYTES ARRAY POINTER : p_aliases   % Alias list
INTEGER             : p_proto     % Protocol number
ENDRECORD

SLgPent reads the next line of the file, opening the file if necessary.

SLsetPent opens and rewinds the file. If the parameter StayOpen is TRUE, the file will not be closed after each call to SLgPent.

SLendPent closes the file.

SLgPbyName and SLgPbyNumber sequentially search from the beginning of the file until a matching protocol name or protocol number is found, or until EOF is encountered. For SLgPbyName, it also matches the aliases.

RETURN STATUS:

NIL pointer if an entry is not found.

# 8.5. Accessing Service Entry

## DECLARATION:
ROUTINE RETURN
ROUTINE VOID, SLservent POINTER SLgetSent
ROUTINE VOID, VOID (BOOLEAN) SLsetSent
ROUTINE VOID, VOID SLendSent
ROUTINE VOID, SLservent POINTER (BYTES, BYTES POINTER) SLgSbyName
ROUTINE VOID, SLservent POINTER (INTEGER, BYTES POINTER) SLgSbyPort

CALLS:

CALL: SLgetSent =: hp
CALL: SLsetSent(stayOpen)
CALL: SLendSent
CALL: SLgSbyName(servicename, Addr protocolname) =: hp
CALL: SLgSbyPort(pnum, Addr protocolname) =: hp

Page 179

DESCRIPTION

SLgetSent, SLgSbyName and SLgSbyPort each return a pointer to an record of the type SLservent, defined in the SLIB:DEFS file. The record contains the broken-out fields of a line in the service name database AIP-SERVICES:SYMB. The record is contained in the local area of SLIB, so it must be copied if it is to be saved.

TYPE SLservent = RECORD
    BYTES            : s_name(0:31)      % Official service name
    BYTES ARRAY POINTER : s_aliases       % Alias list
    INTEGER          : s_port            % Port number
    BYTES            : s_proto(0:31)     % Name of protocol
ENDRECORD

SLgetSent reads the next line of the file, opening the file if necessary.

SLsetSent opens and rewinds the file. If the parameter StayOpen is TRUE, the file will not be closed after each call to SLgetSent.

SLendSent closes the file.

SLgSbyName and SLgSbyPort sequentially search from the beginning of the file until a matching service name or port number is found, or until EOF is encountered. For SLgSbyName, it also matches the aliases. If the protocol name is supplied (not NIL), searches must also match the protocol.

RETURN STATUS

NIL pointer if an entry is not found.


Page 180

8.6. SLhtonl, SLhtons, SLntohl, SLntohs

DECLARATION:

ROUTINE VOID, INTEGER4 (INTEGER4) : SLhtonl
ROUTINE VOID, INTEGER2 (INTEGER2) : SLhtons
ROUTINE VOID, INTEGER4 (INTEGER4) : SLntohl
ROUTINE VOID, INTEGER2 (INTEGER2) : SLntohs

CALL:
SLhtonl(hostLong)
CALL:
SLhtons(hostShort)
CALL:
SLntohl(netLong)
CALL:
SLntohs(netShort)

DESCRIPTION:

SLhtonl
Convert 32-bit quantity from host to network byte order.

SLhtons
Convert 16-bit quantity from host to network byte order.

SLntohl
Convert 32-bit quantity from network to host byte order.

SLntohs
Convert 16-bit quantity from network to host byte order.

These routines manipulate variable-length byte strings and handle byte swapping of network addresses and values.

These byte-swapping routines are provided because the operating system expects addresses to be supplied in network order. On some computers this is reversed. Consequently, programs are sometimes required to byte swap quantities. The library routines which return network addresses provide them in network order, so they may simply be copied into structures provided by the system. This means that an application encounters the byte-swapping problem only when interpreting network addresses.


Page 181

Chapter 9

INTERNET ADDRESS MANIPULATION ROUTINES


Page 182

I'm sorry, but the page is blank. There is no content to transcribe or convert to Markdown.


Page 183

9.1. Internet "." Notation

Values specified using the "." notation take one of the following forms:

  • a.b.c.d
  • a.b.c
  • a.b
  • a

When four parts are specified, each is interpreted as a byte of data and assigned, from left to right, to the four bytes of an Internet address.

When a three-part address is specified, the last part is interpreted as a 16-bit quantity and placed in the two rightmost bytes of the network address. This makes the three-part address format convenient for specifying Class B network addresses as "128.net.host".

When a two part address is specified, the last part is interpreted as a 24-bit quantity and placed in the right most three bytes of the network address. This makes the two part address format convenient for specifying Class A network addresses as "net.host".

When only one part is given, the value is stored directly in the network address without any byte rearrangement.

All numbers supplied as parts of "." (dot) notation are interpreted as decimal.


Page 184

9.2. SLinNetAddr - Convert Internet '.' Notation to Binary Format


DECLARATION:

ROUTINE VOID, INTEGER (BYTES, SLinaddr WRITE) : SLinNetAddr

CALL:

SLinNetAddr(cp, jaddr) =: status

DESCRIPTION:

SLinNetAddr interprets ASCII character strings representing numbers expressed in the Internet standard '.' notation, returning numbers suitable for use as Internet addresses.

PARAMETERS:

Parameter Description
cp Specifies the Internet address in Internet '.' notation.

RETURN STATUS:

Status Description
SLEok Successful call.
1 Could not convert the Internet address in a binary format.

Page 185

Chapter 10.

TROUBLE SHOOTING


Page 186

I'm sorry, but this page is blank.


Page 187

10.1. How to Check a TCP Connection

To check that your local TCP/IP can reach the TCP on another host, simply use the FTP or TELNET client and try to connect to the other host. See the example below.

@FTP-CLIENT  
-------- FTP CLIENT ND-211154C00 - September 21, 1988 --------
Ftp> OPEN F 
Trying...
Connected to f.
220 f FTP server.BA ready. AQC September 12, 1988
Username on f: FL-US 
331 Password for FL-US.
password: 
230 User FLOPPY-USER logged in.
Ftp> QUIT 
221 Goodbye.

Table no. 13. FTP Client

If the other host has FTP/TELNET service, you will be connected. If it does not, you will get the error message:

SLconnect: Connection Refused

This error message means the connection to the TCP is OK, but the TCP did not have the requested service. If the TCP connection is not OK, you will get the error message:

SLconnect: Connection timed out


Page 188

Troubleshooting

ND-860372.1 EN

If you receive this error message, you should check the connection to the remote IP, by use of the TCP/IP monitor PING command. This command will tell you whether it is possible to reach the remote IP from your local TCP/IP. See the example below.

Slb: PING othersystem ↵

Ping: othersystem 130.67.11.1 OK

"othersystem OK" means you have contact with the remote IP. If your PING message does not go through, you will have "No contact" returned.

Normally, if the FTP client or the TELNET client open give "connection timed out", the PING will not work either. If, however, the PING command works, and the open command does not, this means something is wrong with the remote TCP.

If you do not manage to contact the remote TCP/IP, try to contact other hosts in the network. If you do not manage to contact other hosts in the network, check your own host's connection to the network.

Note that the PING command is often implemented in other vendors' software as well.

+-----------------------------------------+
| NOTE:                                   |
|                                         |
| If you are using PING against other     |
| vendors, you might get "No contact"     |
| simply because the other vendor has     |
| no support for incoming PING messages.  |
| The TCP/IP software in our OWS does not |
| support it!                             |
+-----------------------------------------+

If the remote host has no support for PING, use only the open FTP or TELNET client.


Page 189

SINTRANS LJB Programmer's Guide

ND-860372.1 EN


NOTE:
If the TCP connection was not okay, check that the network part of their IP address is equal. If not, it will not be possible to establish a TCP connection between them. For a further description of IP addresses, see the OpenLAN Network Supervisor Guide (ND-830107).

10.1.1. How to Check Local TCP Controller/Network Connection

NOTE:
You cannot check the connection to the network cable by using FTP/TELNET or PING against yourself!

If you are running the TCP/IP Basic Module:

Check your local TCP controller by using the Ethernet III controller selftest as described in the Ethernet III controller manual. If the selftest fails, this is usually because the controller is not connected to the network.

10.1.2. In-depth Debugging of Error Situations

When using the TCP/IP Basic Module software, it is possible to trace TCP.



Page 190

10.1.2.1. How to Install the Internal TCP/IP Trace Tool

To install the trace tool, copy the following files from the diskette 211327Axx-XX-03D to user TCP/IP (or another user with public read access):

TRACE-RT:MODE
TRACE-RT-L:PROG

From user SYSTEM, run the mode file TRACE-RT-L:MODE to load the TRACERT program. The TCP/IP trace tool is now installed, and the internal tracing in TCP/IP is ready to be used by the TCP/IP monitor commands START-TRACE and STOP-TRACE.

10.1.2.2. Internal Tracing in TCP/IP

Internal tracing is used to debug the TCP protocol, trace queue/resource manipulation in TCP/IP, trace messages from upper/lower levels etc. We have the following trace levels (trace level given by setting bits in a trace mask).

Bit Trace Level Description
bit 0= 1B: User events/messages
bit 1= 2B: Aip events/messages
bit 2= 4B: Memory buffer queue manipulation
bit 3= 10B: Send and receive queue manipulation
bit 4= 20B: Sequence (receive) queue state
bit 5= 40B: SuperKernel events
bit 6= 100B: Bad messages/datagrams/inconsistency
bit 7= 200B: Line trace on user interface
bit 8= 400B: Line trace on IP interface
bit 0-31= -1: Trace any event/message (full trace)

The most useful trace levels will probably be "Line trace on user interface" and "Line trace on IP interface", which will show packets sent from/received by TCP. Another useful trace level will probably be [illegible].


Page 191

SINTRAN SLIB Programmer's Guide

"Bad messages/datagrams/inconsistency"

Below is an example of tracing on packets to/from TCP. Always remember to do ABORT/RT on TRACERT before starting the tracing.

@ABORT TRACERT
@RT TRACERT
@TCPIP-MONITOR

TCPIP-MONITOR version A0C of September 14, 1988

Slib:START-TRACE
Trace Mask : 256          $400B in decimal
Tcp device number (1-15) : 4
Trace file Name (continuous) : TCP-TRACE:DATA
Slib:

NOTE:

RT is the default user name for the file names in the START-TRACE and STOP-TRACE commands.

The trace is now started, trace information being output to the file (RT)TCP-TRACE:DATA. When the sequence you wish to trace is finished, you can stop the trace by using the STOP-TRACE command, (see the example below).

NOTE:

You must not leave the monitor between the START-TRACE and STOP-TRACE commands!


Page 192

Troubleshooting ND-860372.1 EN

TCP Trace Output

$lib:STOP-TRACE
Trace file Name : TCP-TRACE:OUT
No message waiting
$lib:

You can use an editor to inspect the file TCP-TRACE:OUT, where you will find the trace information in readable format. Below is an example of how the trace given from the previous examples may look.

TcpInput......enter, time: 1.57.32.48
 Protocol: 6, Length: 24, Source port: 1087, Dest port: 21
 Source addr: 130.67.11.88, Dest addr: 130.67.11.94
 Seq no. 22716737, Ack no. 0, Window: 2048, Checksum: 53166
 Flags: SYN , to SlAp: 795652, connid: 4

SendPacket.....sending packet, time: 1.57.32.49
 Protocol: 6, Length: 24, Source port: 21, Dest port: 1087
 Source addr: 130.67.11.94, Dest addr: 130.67.11.88
 Seq no. 929343, Ack no. 22716738, Window: 4096, Checksum: 39248
 Flags: SYN ACK , from SlAp: 795752, connid: 9

10.1.3. Inspecting TCP/IP Status

The NETSTAT command in the TCPIP monitor is used for inspecting the status of the software. The NETSTAT command prints out statistics from both Ethernet Media Access (MAC) and the TCP/IP itself.

Statistics from MAC can give you a hint when something is wrong with the Ethernet. The TCP/IP statistics let you see how many active connections TCP has, which services are used (FTP, TELNET, OWS Access) and which hosts are connected. On the following page are some examples of how to use the NETSTAT command.


Page 193

SINTRAN SLIB Programmer's Guide

Slib:NETSTAT a

Prot Recv-Q-Send Local address Port Foreign address Port State
TCP 0 0.0.0.0 23 0.0.0.0 0 LISTEN
TCP 0 0.0.0.0 7 0.0.0.0 0 LISTEN
TCP 0 0.0.0.0 21 0.0.0.0 0 LISTEN
TCP 0 0.0.0.0 551 0.0.0.0 0 LISTEN
TCP 0 0.0.0.0 560 0.0.0.0 0 LISTEN
TCP 0 0.0.0.0 561 0.0.0.0 0 LISTEN
TCP 12 0.128.39.3.105 551 128.39.55.107 826 ESTABLIS
TCP 0 0.0.0.0 0 0.0.0.0 0 SAME
TCP 0 128.39.3.105 23 128.39.3.103 1047 ESTABLIS

End Netstat command.
Slib:

The "a" option in the NETSTAT command is used for displaying the active TCP connections. You can see what service is being used, and the IP addresses of the connected hosts. The connections in the "LISTEN" state, with zero in local and foreign address, are servers waiting for incoming requests. The port number tells you which service it is. In the example above, you can see that the following servers are started: TELNET server (port 23), FTP server (port 21), OWS Access server (port 551), SIBAS Routing server (port 561), SIBAS communication server (port 560), and the echo server (port 7). The last is used for testing.

Remember that port numbers 0 to 1023 are reserved for privileged users. The ports with a number equal to or greater than 1024 are the ones assigned to the other users by TCP. For a summary of the "privileged port numbers", see the file (SYSTEM)AIP-SERVICES:SYMB.


Page 194

Netstat Command

Ethernet Media Statistics

lance Ethernet interface
1 = version number of MA type
772663 total successful transmissions
411 transmitted after one collision
442 transmitted after multiple collisions
0 aborted transmission (excess collisions)
754001 frames received and sent to user
0 dropped since no user receive request
121171 no buffer for receive frame
1 received with bad CRC
0 octet alignment errors
0 internal FIFO overflow
0 incoming frame exceeded buffer length
0 MA length field not in accord with frame length
0 number of restarts performed by ENMA
0 carrier lost during transmit
0 bad received frame length read
0 frame received, should not have passed check
0 jabber detected
0 transmit underflow
0 collision outside window => not sent
0 no heartbeat from transceiver
0 LANCE got no response in time
0 transmit channel hung
End Netstat command.

Notes

The "i" option in the NETSTAT command is useful for displaying Ethernet Media statistics. This may be useful if you suspect there is something wrong on the network.

For a further description of these statistics, see the following section: Some TCP/IP Monitor Calls.

However, we want you to be especially aware that there are normally not many retransmissions or CRC errors. This may indicate errors in a controller, or noise in the network itself. If you have problems with the communication over Ethernet (connections drop etc.), check if there are many retransmissions/CRC errors in the statistics printout.


Page 195

SINTRAN SLIB Programmer's Guide

Errors in the Local Controller

Try to check it at intervals to see if it increases.

It is a bit difficult to tell what the various statistics mean. As a general rule, you might say that the following statistics mean errors in the local controller:

  • no buffer for receive frame
  • octet alignment errors
  • internal FIFO overflow
  • transmit underflow
  • LANCE got no response in time
+-----------------------------------------------+
| NOTE:                                         |
|                                               |
| These errors do not necessarily have to be    |
| fatal, but they may indicate either an error  |
| or that the load on the controller is/has     |
| been heavy! In the printout example above,    |
| the "no buffer for receive frame" count was   |
| high, but the communication did not fail.     |
+-----------------------------------------------+

Network or Local/Remote Controller Errors

For the following errors, it is difficult to say if they are caused by the network or by a local/remote controller.

  • jabber detected
  • aborted transmissions
  • carrier lost during transmit
  • No heartbeat from tranceiver
  • received with bad CRC
  • incoming frame exceeded buffer length
  • MA length field not in accord with frame length
  • bad received frame length read
  • frame received, should not have passed check
  • collision outside window ⇒ not sent
  • transmit channel hung

Page 196

Troubleshooting

ND-860372.1 EN

If you have several TCP/IP software installations in the network, try to check the others as well. If, for instance, one controller reports a lot of CRC errors, and the others do not, then the CRC errors are probably caused by the controller itself. If all the controllers in the network except one report CRC errors, then it is probably the fault of the controller not reporting the error.

Slib:NETSTAT m

Mbuf statistics:
160 entries, 90 in use, 70 free, 10 drops totally

Mbuf types:    reserved  drops
  mt_free....:       70      0
  mt_data....:        2      4
  mt_header..:      .35      0
  mt_deliver.:       53      6
  mt_rcvoob..:        0      0
  mt_extoob..:        0      0
  mt_udpdtgm.:        0      0
  mt_aiparp..:        0      0
  mt_aipdtgm.:        0      0
End Netstat command.
Slib:

The "m" option in the NETSTAT command will show the TCP buffer statistics. Be aware of drops! If there are drops on any buffer type, this means a message has been lost! For buffers of types mt_header (buffers to the net) and mt_deliver (buffers from the network), retransmissions will be carried out, but for buffers of type mt_data (buffers from SLIB), the data is really lost!

To see which version of the software is running you have the TCPIP-Monitor LIST-VERSION command, (see the example on the following page). This command also displays the IP address, gateway address, and subnet mask.


Page 197

SINTRAN SLIB Programmers Guide

ND-860372.1 EN

Slib:LIST-VERSION

Field Value
Internetwork TCP UDP RAW
Generation date July 20, 1988
Version 03B
System type Ethernet III
Port name *TCP4
Aip address 130.67.11.15
Gateway address 0.1.1.2
Network mask (hex) FFFFFE000
Number of connections 70
Number of buffers 200
Up and running for 0h 44m 7s

Configuration options

  • Dynamic Port Name scheme
  • Trace facility
  • Network Statistics
  • Advanced Error reporting
  • Extra code for simulation of network problems
  • Direct activation of processes within the con

Event enable block

0B 0B 0B 0B 0B
55B 24B 24B 0B

Slib


Page 198

10.2. Some TCPIP Monitor Commands

Command name: TEST-GENERATE

Number Parameter name Default value
1 Number of TPDUs to send
2 Size in bytes of TPDUs
3 Name of remote computer

Explanation of parameters:

  1. How many messages do you wish to send to the remote computer?

  2. What is the size of the messages?

  3. Name of the remote computer.

Rule(s):

Can be used against ND's TCP/IP in Ethernet III, and any other vendor supporting the Echo protocol.

Function:

Sends messages to a remote echo server, and has them returned. Useful for stressing the TCP/IP, and for doing performance measurements.


Page 199

Command Name: LIST-HOSTS

Number Parameter Name Default Value
<NO PARAMETERS>

Related Commands:
NETSTAT, PING

Function:
Lists every entry on the hosts file on the local computer ((SYSTEM)AIP-HOSTS:SYMB).

Explanation to Output:
Prints the Internet address, followed by the official name, and then the aliases.


Page 200

Command Name: NETSTAT

Number Parameter Name Default Value
1 Kind of statistics a

Explanation of Parameters:

  1. A - Give information about active TCP connections
  2. a - Give more information about active TCP connections
  3. i - List statistics from MAC layer
  4. h - List all hosts in AIP-HOSTS file
  5. m - List buffer statistics in TCP/UDP/RAW layer
  6. n - Same as 'a', but with ASCII host-names instead (not impl.)
  7. r - List routing info (not impl.)
  8. s - List statistics of layers above MAC layer (UDP, ICMP, TCP IP)
  9. t - List timing information

Rule(s):

Function:

Give various statistics from the network software.


Page 201

Explanation of Output

Parameter no. 1 is "a":

(Information about active TCP connections.)

Slib:NETSTAT a

| Prot | Recv-Q-Snd | Local address   | Port | Foreign address   | Port  | State    |
|------|------------|-----------------|------|-------------------|-------|----------|
| TCP  | 0          | 0.0.0.0         | 23   | 0.0.0.0           | 0     | LISTEN   |
| TCP  | 0          | 0.0.0.0         | 7    | 0.0.0.0           | 0     | LISTEN   |
| TCP  | 0          | 0.0.0.0         | 21   | 0.0.0.0           | 0     | LISTEN   |
| TCP  | 0          | 0.0.0.0         | 551  | 0.0.0.0           | 0     | LISTEN   |
| TCP  | 0          | 0.0.0.0         | 560  | 0.0.0.0           | 0     | LISTEN   |
| TCP  | 0          | 0.0.0.0         | 561  | 0.0.0.0           | 0     | LISTEN   |
| TCP  | 12         | 0               | 128.39.3.105 | 551   | 128.39.55.107 | 826 | ESTABLIS |
| TCP  | 0          | 0.0.0.0         | 0    | 0.0.0.0           | 0     | SAME     |
| TCP  | 0          | 128.39.3.105    | 23   | 128.39.3.103      | 1047  | ESTABLIS |

End Netstat command.
Slib:
  • Prot

    The protocol type (either TCP or UDP).

  • Recv-Q-Snd

    Gives number of bytes in the receive and send queues, that is the number of bytes waiting to be transmitted to the application (receivequeue), and the number of bytes waiting to be transmitted to the network (sendqueue).

  • Cid

    Connection identifier for this connection (unique in local TCP).

  • Local address port

    The local IP address and TCP port number for this connection.

  • Foreign address port

    The remote IP address and TCP port number for this connection.


Page 202

State

For TCP connection state, see table 6, TCP State on.

Parameter no. 1 is "A":

Information about active TCP connections:

Slib:NET A

TCPIP-MONITOR connected to tcpdev-0

SlAp     Cid  Snt-Bytes  Rcvd-Bytes  Local port  Foreign port
438416    1        0           0           23         0
438508    2        0           0           21         0
438600    3        0           0          551         0
438692    5        0           0          888         0
438784  172     2126          46          23      1025
438876   260    6301          91          23      1025
439060   195    1857          43          23      1025
439152   221  116347        2687          23      1025
439244   174  341378        3623          23      1025

Slib:EXIT
  • SlAp
    Gives the SlAp address for the information given in the 'a' command. The SlAp (Socket library Access point) address is a unique identifier for this socket.
  • Cid
    Connection identifier for this connection (unique in local TCP).
  • Snt-Bytes
    Bytes sent from the application.
  • Rcvd-Bytes
    Bytes received from the application.
  • Local port
    The local TCP port number for this connection.
  • Foreign port
    The remote TCP port number for this connection.

Page 203

SINTRAN SLI B Programmer's Guide

Parameter no. 1 is "h":

List all hosts.

This command does the same as the LIST-HOSTS command.

Parameter no. 1 is "i":

List statistics from MAC layer.

Slib:NETSTAT i
Ethernet Media statistics:
  lance Ethernet interface
  1 = version number of MA type
  772663 total successful transmissions
  411 transmitted after one collision
  442 transmitted after multiple collisions
  0 aborted transmission (excess collisions)
  754001 frames received and sent to user
  0 dropped since no user receive request
  121171 no buffer for receive frame
  1 received with bad CRC
  0 octet alignment errors
  0 internal FIFO overflow
  0 incoming frame exceeded buffer length
  0 MA length field not in accord with frame length
  0 number of restarts performed by ENMA
  0 carrier lost during transmit
  0 bad received frame length read
  0 frame received, should not have passed check
  0 jabber detected
  0 transmit underflow
  0 collision outside window => not sent
  0 no heartbeat from transceiver
  0 LANCE got no response in time
  0 transmit channel hung
End Netstat command.
Slib:

This command displays Ethernet Media statistics in the same way as the COSMOS Ethernet Monitor does. For a further description, see the manual Ethernet II controller (ND-812055).


Page 204

Parameter no. 1 is "m"

List buffer statistics

Slib:NETSTAT m

Mbuf statistics:

160 entries, 90 in use, 70 free, 10 drops totally

Mbuf types:

Type Reserved Drops
mt_free 70 0
mt_data 2 4
mt_header 35 0
mt_deliver 53 6
mt_rcvoob 0 0
mt_extoob 0 0
mt_udpptgm 0 0
mt_aiaprp 0 0
mt_aipdtgm 0 0

End Netstat command.

Slib:

This command gives statistics from the TCP buffer pool, that is, the buffers used for incoming/outgoing messages. Statistics are displayed for all different kinds of buffers. The different kinds of buffers are listed below.

  • mt_free - Buffers not reserved
  • mt_data - Buffers for receiving data from SLIB
  • mt_header - Buffers for sending data to IP
  • mt_deliver - Buffers for receiving data from IP
  • mt_rcvoob - Not in use
  • mt_extoob - Buffers for receiving out-of-band data
  • mt_udpptgm - Buffers used by the UDP protocol
  • mt_aiaprp - Buffers used for the ARP protocol
  • mt_aipdtgm - Buffers used by IP

Page 205

Buffer Information

For each type of buffer, the following is displayed:

Type Description
reserved How many buffers of this type are currently in use.
drops How many times TCP has failed to get a buffer of this type.

Page 206

Parameter no. 1 is "S"

Network Statistics from TCP

Slib:NET s

TCPIP-MONITOR connected to tcpdev=0

ip:

  • 86053 total number of IP packets received
  • 0 bad IP checksums
  • 0 failed memory requests
  • 0 dropped packets
  • 0 forwarded packets
  • 0 broadcast packets

tcp:

  • 87883 tcp packets received
  • 95257 tcp packets sent
  • 0 bad tcp checksums
  • 0 tcp failed memory requests
  • 300 bad tcp segments (to which we sent RST)
  • 0 tcpsegs placed on rcv_unack
  • 841 retransmissions we sent
  • 36365 acknowledge only packets

icmp:

  • 0 total icmp packets received
  • 0 bad icmp checksums
  • 0 icmp failed memory requests
  • 0 icmp pkts rcvd that were broadcast (ign)
  • 0 icmp messages with invalid type (ignored)
  • 0 icmp source quenches received
  • 0 icmp redirects received
  • 20 icmp echo requests responded to
  • 0 pings received
  • 0 pings actually sent
  • 0 icmp time exceeded messages received
  • 0 icmp parameter problems received

udp:

  • 0 total udp packets received
  • 0 udp packets sent
  • 0 udp bad checksums
  • 0 udp failed memory requests
  • 0 udp drops (no user process wants packet
  • 0 packets dropped due to receive queue full
  • 0 udp packets cannot mget for socket code

Page 207

SINTRAN SLIB Programmer's Guide

ND-860372.1 EN

TCP Packet Statistics

Description Detail
TCP packets received Packets received.
TCP packets sent Packets sent.
Bad TCP checksums Packets received with bad checksum.
TCP failed memory requests TCP has received a packet smaller than the size of a header.
Bad TCP segments (to which we sent RST) The packet was sent to a connection which was not in a state to receive it (perhaps a packet was received on a closed connection).
TCP segments placed on rcv_unack Segments received on connections where our window size was zero (we could not receive the data, so we placed it in a queue to wait for free buffers).
Retransmissions sent Packets retransmitted after timeout.
Acknowledge only packets ACK sent by us.

Notes

Note that only statistics for TCP have been implemented. Statistics for other network software (UDP, ICMP, IP) are not implemented, even if they are displayed.


Page 208

Command Name: ARP

Number Parameter Name Default Value

Related Commands: PING

Function:
Displays the ARP table. The ARP table gives the mapping between Internet addresses and Ethernet addresses. Only remote hosts that have sent to/received from our local host since the last restart of the local TCP/IP are in the ARP table.

Explanation of Output:
The IP addresses are given in decimal, while the Ethernet addresses are given in hex. Where the address is zero, there is none available. IF is the controller number.


Page 209

Command name: PING

Number Parameter name Default value
1 Host name all

Explanation of parameters:

1 Host name

If <cr> or *, then every host in the host table will be tried to be contacted.

Function:

To check if the IP part in the remote host is available.

Explanation of output:

For the required host(s), the TCP/IP monitor will give the name, Internet address, and status. Status can have the following values:

  • OK: Means the connection to the remote host is OK.
  • No contact: No contact with remote host.
  • Error in answer: Host was the local host, or the response contained one or more errors.

Page 210

Command Name: KILL

Number Parameter Name Default Value
1 Connection identifier None

Explanation of Parameters

  1. Connection identifier in the TCP. Will be displayed with the netstatus A command.

Rule(s)

Related Commands: - Netstatus a - Netstatus A

Function

To remove a connection in TCP without rebooting the controller, for example:

Example:

Slib:net A

SlAp  Cid Snt-Bytes Rcvd-Bytes Local port Foreign port
752324  1      0          0       9990       0
752424  2      0          0       9991       0
752524  8      0          0        .0        0

Slib:kill 1
Slib:net A

SlAp  Cid Snt-Bytes Rcvd-Bytes Local port Foreign port
752424  2      0          0       9991       0
752524  10     0          0        0        0

Slib:

The example does two net A commands with a KILL command in between. It is seen that the "killed" Cid has disappeared.


Page 211

Command Name: LIST-VERSION

Number Parameter Name Default Value

List-Domino-Configuration

Explanation of Parameters:

Function:

Lists some of the available configuration information for the TCP/IP software in DOMINO.

Explanation of Output:

  • Internetwork: What protocols are supported upon IP. We currently support TCP, UDP and RAW.
  • Generation Date: Date the software was generated.
  • Version: Software version number.
  • System Type: Type.
  • Port Name: Port name.
  • IP Address: Internet address.
  • Gateway Address: Internet address of gateway to other IP nets.
  • Network Mask (hex): Subnet mask.
  • Number of Connections: Number of simultaneous connections the TCP can handle.
  • Number of Buffers: Number of buffers in the free pool.

Page 212

Trouble Shooting

Up and Running For

How long the controller has been up and running. Time is given in hours, minutes, seconds.

Configuration Options

Compiler options (which parts of the code are included). Should be fixed.

Event Enable Block

Eight different masks for enabling different trace/statistics. The masks are, in order:

  • Trace mask
  • Statistics mask
  • Not in use
  • Printout of Netproblems
  • More statistics
  • Statistics printout interval
  • MBUF statistics printout interval
  • Not in use

Page 213

Command Name: LIST-DOMINO-CONFIGURATION

Number Parameter name Default value

Related Commands:
List-Version

Function:
Displays which Ethernet-III DOMINOS this system has. The information output is basically hardware information.

Explanation of Output:

  • Octo: Octobus station number.
  • Crate: Crate number.
  • Slot: Slot number.
  • Module: Which type of card.
  • Print level: Card print level.
  • ECO level: Card ECO level.
  • Model
  • Image file: Name of the file from which the DOMINO software is loaded.

Page 214

Command Name: REBOOT-CONTROLLER

Number Parameter Name Default Value
1 Octobus station number (dec) None

Related Commands: Place-Image
Function: Reboots an Ethernet-III controller.


Page 215

Command name: PLACE-IMAGE

Number Parameter name Default value
1 Octobus station number (dec) None
2 Image file name None

Explanation of parameters:

Function:

Reboots an Ethernet-III controller with a special image file.


Page 216

Command name: START-TRACE

Number Parameter name Default value
1 Trace Mask None
2 TCP device number (1-15) None
3 Trace file name (continuous ring file) None

Explanation of parameters:

1

TCP trace mask. The meanings of the various bits in the trace mask are explained below:

bit 0=    1B: User events/messages
bit 1=    2B: Aip events/messages
bit 2=    4B: Memory buffer queue manipulation
bit 3=   10B: Send and receive queue manipulation
bit 4=   20B: Sequence (receive) queues state
bit 5=   40B: SuperKernel events
bit 6=  100B: Bad messages/datagrams/inconsistency
bit 7=  200B: Line trace on user interface
bit 8=  400B: Line trace on IP interface
bit 9= 1000B: Data trace enabled

bit 0-31= -1: trace any event/message (full trace)

2

Device number of the TCP controller. For DOMINO controllers, it may range from 4 to 15.

3

File name.

Function:

Starts the tcp trace. Output goes to the ring file.

WARNING:

If you leave the TCPIP-Monitor, the tracing will stop.


Page 217

Command Name: STOP-TRACE

Number Parameter Name Default Value
1 Trace file name None

Explanation of Parameters:

1 Name of the file which the readable trace should be output to.

Function:

Stops the TCP trace. The contents of the ring file are converted to a readable format and placed on the file given as parameter one.


Page 218

Command name: EXIT

Number Parameter name Default value

Function: Leaves the monitor.


Page 219

Appendix A

THE :IMPORT AND :DEFS FILES


Page 220

[Blank Page]

Page 221

The SLIB:DEFS File

The SLIB:DEFS file is listed on the following pages.

**************************************************************
*                                                           *
*                   S O C K E T   L I B R A R Y             *
*                       D E F I N I T I O N S               *
*                                                           *
**************************************************************

ERROR CODES

CONSTANT VALUE DESCRIPTION
SLEok 0 OK
SLEfirst 20225 first error
SLEwksz 20225 work size error
SLEptr 20226 pointer error
SLElilsid 20227 illegal socket ID
SLElostPL 20228 lost contact with PL (packet level)
SLEconstart 20229 error when establishing contact with PL
SLEnospace 20230 no more space
SLEnospinmsg 20231 too little space in message
SLEslibfatal 20232 fatal internal SLIB error
SLEtryagain 20233 used between SLIB and protocols
SLEinval 20234 argument invalid
SLEprototyppe 20235 protocol wrong type for socket
SLEnoprotocoopt 20236 bad protocol option
SLEprotonosupport 20237 protocol not supported
SLEsocktnosupport 20238 socket type not supported
SLEaddrinuse 20239 address already in use
SLEaddrnotavail 20240 cannot assign request address
SLEnetdown 20241 network is down
SLEnetunreach 20242 network is unreachable
SLEnetreset 20243 network dropped connection on reset
SLEconnaborted 20244 software caused connection abort
SLEconnreset 20245 connection reset by peer
SLEisconn 20246 socket is already connected
SLENotconn 20247 socket is not connected
SLEshutdown 20248 cannot send after shutdown
SLEtimedout 20249 connection timed out
SLEconnrefused 20250 connection refused

Page 222

CONSTANTS

CONSTANT VALUE DESCRIPTION
SLEnobufs 20251 % no buffer space available
SLEunexpected 20252 % unexpected subsystem error
SLEwouldblock 20253 % io would have blocked you
SLElast SLEwouldblock % last error

BASIC TYPES

TYPE SLu_char = INTEGER RANGE(0:28 - 1)
TYPE SLu_short = INTEGER RANGE(0:2
16 - 1)
TYPE SLu_int = INTEGER RANGE(0:2**16 - 1)
TYPE SLu_long = INTEGER RANGE(0:37777777777B)
TYPE SLchar = INTEGER1
TYPE SLshort = INTEGER2
TYPE SLcaddr = BYTE POINTER
TYPE SLsockid = INTEGER
TYPE SLrvv = ROUTINE VOID, VOID
TYPE SLrvvp = SLrvv POINTER

SOCKET TYPE

CONSTANT VALUE DESCRIPTION
SOCK_stream 1 % stream socket
SOCK_dgram 2 % datagram socket
SOCK_raw 3 % raw-protocol interface
SOCK_rdm 4 % reliably-delivered message
SOCK_seqpacket 5 % sequenced packet stream

OPTION FLAGS PER-SOCKET

CONSTANT VALUE DESCRIPTION
SO_debug 1 % turn on debugging info recording
SO_acceptconn 2 % socket has had listen()
SO_reuseaddr 4 % allow local address reuse
SO_keepalive 8 % keep connections alive
SO_dontroute 16 % just use interface addresses
SO_useloopback 32 % bypass hardware when possible
SO_linger 64 % linger on close if data present
SO_dontlinger 128 % ~SO_LINGER

SOCKET LEVEL NUMBER

% FOR SLgetsockopt, SLsetsockopt

CONSTANT VALUE DESCRIPTION
sol_socket -1 % options for socket level

Page 223

ADDRESS FAMILIES

CONSTANT Value Description
AF_unspec = 0 unspecified
AF_unix = 1 local to host (pipes, portals)
AF_inet = 2 internetwork: UDP, TCP, etc.
AF_implink = 3 arpanet imp addresses
AF_pup = 4 pup protocols: e.g. BSP
AF_chaos = 5 mit CHAOS protocols
AF_ns = 6 XEROX NS protocols
AF_nbs = 7 nbs protocols
AF_ecma = 8 european computer manufacturers
AF_datakit = 9 datakit protocols
AF_ccitt = 10 CCITT protocols, X.25 etc
AF_sna = 11 IBM SNA
AF_iso = 12 ISO expr.
AF_tcpdebug = 13
AF_rdpdebug = 14
AF_max = 15

INTERNET PROTOCOL NUMBERS

CONSTANT Value
in_pro_tcp = 6
in_pro_udp = 17
in_pro_icmp = 1

INTERNET TCP PORT NUMBERS

CONSTANT Value Description
TCP_ftpd = 20 File Transfer (default data)
TCP_ftpc = 21 File Transfer (control)
TCP_telnet = 23 Telnet

SOCKET ADDRESS

TYPE SLinaddr = RECORD PACKED   % internet address class B
  SLu_char : in_b1, in_b2, in_b3, in_b4
  SLu_short: in_w1 = in_b1.
  SLu_short: in_w2 = in_b3
  SLu_long : in_l1 = in_b1
ENDRECORD
TYPE SLsockaddr = RECORD        % socket address general part
  SLu_short: sa_family MOD 2    % address family
ENDRECORD

Page 224

TYPE SLin_sockaddr

TYPE SLin_sockaddr = SLsockaddr RECORD % socket address internet style
    SLu_short: sin_port MOD 2       % internet port number
    SLinaddr: sin_addr MOD 2
ENDRECORD

Record Used with slsendv

CONSTANT SliOVMAX = 8
TYPE Sliovwt = RECORD
    BYTE POINTER: sliov_base
    INTEGER: sliov_len
ENDRECORD
TYPE Sliov = RECORD
    INTEGER: sliov_cnt
    sliovvt ARRAY: sliov_vect(0:SliOVMAX)
ENDRECORD

HOST ENTRY

TYPE SLhostent = RECORD
    BYTES: h_name(0:31)             % official name of host
    BYTES ARRAY POINTER: h_aliases  % alias list
    INTEGER: h_addrtype             % host address type
    SLinaddr: h_addr                % address
    BYTES POINTER: h_comment
ENDRECORD

NETWORK ENTRY

TYPE SLnetent = RECORD
    BYTES: n_name(0:31)             % official name of net
    BYTES ARRAY POINTER: n_aliases  % alias list
    INTEGER: n_addrtype             % net address type
    SLinaddr: n_addr                % network address
ENDRECORD

Page 225

Service Entry

TYPE SLservent = RECORD
  BYTES        : s_name(0:31)       % official service name
  BYTES ARRAY POINTER : s_aliases   % alias list
  INTEGER      : s_port             % port number
  BYTES        : s_proto(0:31)      % name of protocol
ENDRECORD

Protocol Entry

TYPE SLprotoent = RECORD
  BYTES        : p_name(0:31)       % official service name
  BYTES ARRAY POINTER : p_aliases   % alias list
  INTEGER      : p_proto            % protocol number
ENDRECORD

SLICTL Request

CONSTANT VALUE DESCRIPTION
SLiocNBIO 1 set/reset nonblocking io.
SLiocNOACT 2 set no activity timer
SLiocGNOACT 3 get no activity timer
SLiocSOEV 4 Set event bits for the socket
SLiocSSEV 5 Set routine called when strange events from SK
SLiocGActConn 6 Get active connections
SLiocGMbStat 7 Get mbuf statistics
SLiocGNetwork 8 Get network statistics
SLiocGArpTable 9 Get arp table
SLiocGHwStat 10 Get hardware statistics
SLiocGGenInfo 11 Get generation information
SLiocGLoad 12 Get load information
SLiocSAIpAddr 13 Set Aip Address
SLiocKill 14 Kill SLap in PIOC/DIOC
SLiocGTimers 15 Get timer information
SLiocDIEV 16 disable SLIB waiting for these
SLiocSndQue 17 get info in socket sendque only for DOMINO/PIOC

Page 226

RECORD TO BE USED BY SLIOCTL

TYPE SLocArg = RECORD
ENDRECORD

TYPE SLocINT = SLocArg RECORD
    INTEGER4 : SLocNumber MOD 2
ENDRECORD

TYPE SLri4i4 = ROUTINE INTEGER4, INTEGER4
TYPE SLocRout = SLocArg RECORD % used when SLocSSEV
    SLri4i4 POINTER : SLocRoutName MOD 2
ENDRECORD

TYPE SLocTSndQue = SLocArg RECORD
    INTEGER4 : SLocSQused
    INTEGER4 : SLocSQfree
ENDRECORD

Statistics for Active Connections

TYPE SLocActConn = SLocArg RECORD PACKED % packed!
    INTEGER4: STAaddr     % address of requested/returned SIAp (0 if none)
    INTEGER4: STAnext     % address of next SIAp (0 if none)
    INTEGER2: STARcvQ     % size of receive queue in bytes
    INTEGER2: STAsndQ     % size of send queue in bytes
    SLin_sockaddr: STAldaddr % local address, 8 bytes
    SLin_sockaddr: STAfaddr  % foreign address, 8 bytes
    INTEGER2: STAconid    % local interface conn id
    BYTE: STAproto        % protocol type: TCP, UDP, ...
    BYTE: STAstate        % connection state for TCP
    INTEGER4: STAbytes    % no of bytes sent
    INTEGER4: STARbytes   % no of bytes received
    BYTES: STAbtyes(0:39) = STAaddr
ENDRECORD

Get Generation Information

TYPE SLocGenInfo = SLocArg RECORD PACKED % packed!
    INTEGER4: GENconfig   % configuration mask
    INTEGER4: GENconnections % maximum no. of connections
    INTEGER4: GENmbufs    % maximum no. of mbufs
    INTEGER4: GENactiveTime % number of seconds since started
    INTEGER4: GENipaddr   % Aip address
    INTEGER4: GENgatewayaddr % Gateway address
    INTEGER4: GENnetmask  % Network mask (from Aip)
    INTEGER4: GENdummy1   % spare (not yet used)
ENDRECORD

Page 227

SINTRAN SLIB Programmers Guide

GEN Configuration

Type Name Description
INTEGER4 GENdummy2 % spare (not yet used)
INTEGER4 GENdummy3 % spare (not yet used)
BYTE GENlen1 MOD 2 % # of significant bytes in GENdate
BYTES GENdate(0:31) MOD 2 % generation date (e.g. '1 April, 1988')
BYTE GENlen2 MOD 2 % # of significant bytes in GENversion
BYTES GENversion(0:5) MOD 2 % version (e.g. 'B00')
BYTE GENlen3 MOD 2 % # of significant bytes in GENsystem
BYTES GENsystem(0:15) MOD 2 % system (e.g. 'Ethernet II')
BYTE GENlen4 MOD 2 % # of significant bytes in GENportname
BYTES GENportname(0:31) MOD 2 % port name (e.g. '*TCP')
BYTE GENlen5 MOD 2 % # of significant bytes in GENeventinfo
BYTES GENeventinfo(0:63) MOD 2 % Trace/statistics/error/netproblem event block
BYTE GENlen6 MOD 2 % # of significant bytes in GENext1
BYTES GENext1(0:31) MOD 2 % spare (not yet used)
BYTE GENlen7 MOD 2 % # of significant bytes in GENext2
BYTES GENext2(0:31) MOD 2 % spare (not yet used)
BYTE GENlen8 MOD 2 % # of significant bytes in GENext3
BYTES GENext3(0:31) MOD 2 % spare (not yet used)
BYTES GENbytes(0:Size(SLiocGenInfo)-1) = GENconfig

Define Mbuf Types

Constant Value Description
mt_free 0 % should be on free list
mt_data 1 % receive data from user
mt_header 2 % send packet header
mt_deliver 3 % receive data from AIP
mt_rcvoob 4 % out-of-band data from user
mt_extoob 5 % extract incoming out-of-band data
mt_updtgm 6 % send UDP datagram
mt_aiparp 7 % AIP arp (dedicated to AIP)
mt_aipdtgm 8 % AIP datagram (for use by AIP)
mt_max_val mt_aipdtgm % max buffer type (see mb_mtypes)

Mbuf Statistics

TYPE SLiocMbStat = SLiocArg RECORD
    INTEGER2 : mb_mbufs          % mbufs obtained from page pool
    INTEGER2 : mb_mfree          % mbufs on our free list
    INTEGER2 : mb_drops          % times failed to find space
    INTEGER2 ARRAY: mb_mtypes(0:mt_max_val) % type specific mbuf allocations
    INTEGER2 ARRAY: mb_mtdrop(0:mt_max_val) % times failed to get an mbuf
    BYTES    : mb_mbytes(0:Size(SLiocMbStat)-1) = mb_mbfs
ENDRECORD
TYPE SLiocNetwork = SLiocArg RECORD

Page 228

Technical Statistics

IP Packet Statistics

INTEGER4 Description
ip_total % total # ip packets received
ip_badsum % #bad ip checksums
ip_tooshort % #couldn't pullup ip header
ip_drops % #ip packets not addressed to us, not fwded
ip_forwarded % #ip packets not addressed to us
ip_broadcast % #broadcast packets received

TCP Packet Statistics

INTEGER4 Description
t_total % total # TCP packets received
t_sndtotal % total # TCP packets sent
t_badsum % #bad TCP checksums
t_tooshort % #couldn't pullup TCP header
t_badsegs % #bad TCP segments (to which we send RST)
t_unack % #TCP segs placed on rcv_unack
t_retransmit % #retransmissions we sent
t_ackonly % #send_pkt just to send ack, no data

ICMP Packet Statistics

INTEGER4 Description
ic_total % total # ICMP packets received
ic_badsum % #bad ICMP checksums
ic_tooshort % #couldn't pullup ICMP header
ic_broadcast % #ICMP pkts rcv that were broadcast (ign)
ic_drops % #ICMP messages with invalid type (ignored)
ic_quenches % #ICMP source quenches received
ic_redirects % #ICMP redirects received
ic_echoes % #ICMP echo requests respond to
ic_svpings % #pings saved by -l hack
ic_pings % #pings actually sent
ic_timex % #ICMP time exceeded messages received
ic_parm % #ICMP parameter problem received

UDP Packet Statistics

INTEGER4 Description
u_total % total # UDP packets received
u_sndtotal % total # UDP packets sent
u_badsum % #UDP bad checksums
u_tooshort % #couldn't pullup UDP header
u_drops % #UDP drops (no user process wants packet)
u_sonospace % #UDP pkts user socket rcv buf full (drop)
u_nobuf % #UDP pkts can't m_get for socket code

Other Packet Statistics

INTEGER4 Description
o_total % total # other packets received

Additional Information

BYTES: nS_bytes(0:SlicocNetwork)-1) = ip_total
ENDRECORD
%

% hardware statistics
%

TYPE LNMAtype = ENUMERATION(LNMA2cardEthernet, % original Ethernet
                             LNMAlanceEthernet, % LANCE ethernet

Page 229

SINTRAN SLB Programmers Guide

ND-860372.1 EN

LNMAtokenRing,&    % guess
LNMAtokenBus,&
LNMAfddi)

TYPE Slioclnmast = SliocArg RECORD PACK

Field Data Type Description
LNMAtype BYTE defines interpretation of following record
LNMASTversion BYTE statistics version number for that MA type
ENMASTtransmitted INTEGER4 total successful transmissions (after N retransmissions, 0<=N<=15)
ENMASToneCollision INTEGER4 transmitted after one collision
ENMASTmultiCollision INTEGER4 transmitted after multiple collisions
ENMASTaborted INTEGER2 aborted transmission (excess collisions)
ENMASTreceived INTEGER4 frames received and sent to user
ENMASTdropped INTEGER4 dropped since no user receive request
ENMASTmissed INTEGER4 no buffer for receive frame
ENMASTcrcErrors INTEGER2 received with bad CRC
ENMASTalignErrors INTEGER2 octet alignment errors
ENMASTfifoOverflow INTEGER2 internal FIFO overflow
ENMASToverflow INTEGER2 incoming frame exceeded buffer length
ENMASTbadMAlength INTEGER2 MA length field not in accord with frame length
ENMASTrestarts INTEGER2 number of restarts performed by ENMA
ENMASTlossOfCarrier INTEGER2 carrier lost during transmit
ENMASTbadLength INTEGER2 bad received frame length read (outside min/max frame size limits)
ENMASTbadAddress INTEGER2 frame received which should not have passed address check
ENMASTjabber INTEGER2 jabber detected
ENMASTunderflow INTEGER2 transmit underflow
ENMASTlateCollision INTEGER2 collision outside window => not sent
ENMASTheartbeatGone INTEGER2 no heartbeat from transceiver
ENMASTmemoryError INTEGER2 LANCE got no response in time
ENMASThangingTransmit INTEGER2 transmit channel hung

ENDRECORD

TYPE SliocArpTable = SliocArg RECORD PACKED

Field Data Type Description
TARPinterf INTEGER2 interface number
TARPipAddr INTEGER4 IP address
TARPethAddr(0:5) BYTES Ethernet Address
TARPbytes(0:11) BYTES = TARPinterf

ENDRECORD

%
% Record for timer reports
%

CONSTANT maxTimeType = 12

TYPE SliocTimers = SliocArg RECORD PACKED

Field Data Type Description
TIMaddr INTEGER4 address of req SlAp or next higher (0 if none)

Page 230

Technical Information

TIM Variables

INTEGER4 : TIMnext          % address of next SLap (0 if none)
INTEGER2 : TIMconid
INTEGER2 unsigned ARRAY: TIMlim(0:maxrTimeType)   % to contain timers
BYTES    : TIMbytes(0:35) = TIMaddr               % whole record as bytes

SLMAXIMA

TYPE SLmaxima = RECORD
  INTEGER : max_nports       % Max number of ports (TCP,UDP...)
  INTEGER : max_nsockets     % Max number of sockets
  BOOLEAN : max_debug        % TRUE if debug print mode on.
  INTEGER : max_debfd        % file number for debug print
  INTEGER POINTER POINTER : max_AUserDatap   % address of user data pointer
  INTEGER : max_nsallocmsg   % number of small allocated messages
  INTEGER : max_nballocmsg   % number of big allocated messages
  INTEGER : max_tcpdev       % device number for TCP
ENDRECORD

TCP DEVICE VALUES

CONSTANT SLDominioPioc  = -1  % DOMINO first then PIOC
CONSTANT SLPiocDomino   = -2  % PIOCS first then DOMINOS
CONSTANT SLDominoOnly   = -3
CONSTANT SLPiocOnly     = -4

SKP Parameters

Define SKP parameters used by SLIB to determine the size of the DYNAMIC storage must be provided to the SKP library in SKPinit

CONSTANT SLMXtinerEvents    = 5   % max outstanding timer events
CONSTANT SLMXopenPorts      = 5   % max open ports
CONSTANT SLMXremotePorts    = 5   % max references to remote ports
CONSTANT SLMXqueuedMessages = 40  % max owned messages

Working Area for SLIB

CONSTANT used in provision of working area for SLIB. The user must provide a fixed-size work area for SLIB via SLinit.

INTEGER ARRAY : WorkArea(0: SLSzWorkArea - 1)

where SLSzWorkArea is calculated below. The user must define those constants first:

  • SLMaxPorts : maximum number of ports

Page 231

SINTRAN SLIJB Programmers Guide

ND-860372.1 EN

%  - SLMaxSockets    : maximum number of sockets
%  - SLMaxSLFork     : the maximum number of simultaneous active subtaskes.
%  - SLMainTaskStackSize: size of the stack for the maintask routine
%  - SLSubTaskStackSize: size of the subtaskroutines stack used by SLFork
%-------------------------------------------------------------------------------%
$IF $TARGET-machine = 100 $then
%-- ONLY FOR ND100 VERSION !
CONSTANT SzGlobalType  = 52
CONSTANT SzSockTabType = 2
CONSTANT SzPortType    = 22
CONSTANT SzSockType    = 74
CONSTANT Szjob_desc    = 32
CONSTANT SzMsgDesc     = 4

$ELSIF $TARGET-MACHINE = 186 $THEN
CONSTANT SzGlobalType  = 44
CONSTANT SzPortType    = 26
CONSTANT SzSockTabType = 2
CONSTANT SzSockType    = 68
CONSTANT Szjob_desc    = 42
$ELSIF $TARGET-MACHINE = 500 $THEN
CONSTANT SzGlobalType  = 100
CONSTANT SzPortType    = 32
CONSTANT SzSockTabType = 4
CONSTANT SzSockType    = 104
CONSTANT Szjob_desc    = 56
CONSTANT SzMsgDesc     = 8
$ELSIF $TARGET-MACHINE = 68000 $THEN
  $IF eth_ii $THEN
  CONSTANT SzGlobalType  = 96
  CONSTANT SzPortType    = 32
  CONSTANT SzSockTabType = 4
  CONSTANT SzSockType    = 96
  CONSTANT Szjob_desc    = 54
  CONSTANT SzMsgDesc     = 8
  $ELSE
  CONSTANT SzGlobalType  = 98
  CONSTANT SzPortType    = 32
  CONSTANT SzSockTabType = 4
  CONSTANT SzSockType    = 100
  CONSTANT Szjob_desc    = 56
  CONSTANT SzMsgDesc     = 8
  $ENDIF
$ELSE
$MESSAGE illegal target machine

Page 232

$EXIT
$ENDIF
XEPY
$IF FALSE $THEN %$if SLMaxPorts = 0 $then %$IF NOT $PRESENT &
SLMaxPorts $THEN
CONSTANT    SLMaxPorts          = 1  % ARBITRARY
CONSTANT    SLMaxSockets        = 5  % ARBITRARY
CONSTANT    SLMainTaskStackSize = 1000 % ARBITRARY
CONSTANT    SLMaxSLFork         = 10 % ARBITRARY
CONSTANT    SLSubTaskStackSize  = 500 % ARBITRARY
$ENDIF

% PLAN C storage manager overhead is:
CONSTANT SLSZfixedSM = (18*Size(BYTE POINTER))+Size(INTEGER)+100 % fixed overhead (bytes)
CONSTANT SLSZperItemSM = Size(BYTE POINTER)+Size(INTEGER) % per item overhead (bytes)

CONSTANT: SLSZWorkArea = ( SLSZfixedSM + &
                           {SzGlobalType + SLSZperItemSM} + &
                           SLMaxPorts * (SzPortType + SLSZperItemSM) + &
                           SLMaxSockets * (SzSockTabType + SLSZperItemSM) + &
                           SLMaxSockets * (SzMsgdesc + SLSZperItemSM) + &
                           SLMaxSockets * (SzSockType + SLSZperItemSM) + &
                           {Sz_job_desc + SLSZperItemSM} + &
                           SLMainTaskStackSize + SLSZperItemSM + &
                           SLMaxSLFork * (Sz_job_desc + SLSZperItemSM) + &
                           SLMaxSLFork * (SLSubTaskStackSize + SLSZperItemSM) & 
                         )/Size(INTEGER)

$EOF

Page 233

The SLIB:IMPT File

The SLIB:IMPT file is listed on the following pages.

%============================================================================%
%
%                        S O C K E T   L I B R A R Y
%
%                        I M P O R T   D E C L A R A T I O N S
%
%============================================================================%

XEPY
IMPORT (ROUTINE VOID, INTEGER(INTEGER ARRAY POINTER, SLmaxima, SLrvvp, &
  INTEGER, INTEGER POINTER): &
  SLinit), &
(ROUTINE VOID, INTEGER (SLrvvp, INTEGER, INTEGER POINTER): &
  SLfork), &
(ROUTINE VOID, VOID: &
  SLexit), &
(ROUTINE VOID, VOID (INTEGER4, INTEGER4, INTEGER4 WRITE): &
  SLsleep), &
(ROUTINE VOID, VOID (INTEGER4): &
  SLsleepShort), &
(ROUTINE VOID, VOID (INTEGER4): &
  SLsetOwnEvent), &
(ROUTINE VOID, INTEGER (INTEGER, INTEGER, INTEGER, SLsockid WRITE): &
  SLsocket), &
(ROUTINE VOID, INTEGER (SLsockid, SLsockaddr): &
  SLbind), &
(ROUTINE VOID, INTEGER (SLsockid, SLsockaddr WRITE): &
  SLgetsockname), &
(ROUTINE VOID, INTEGER (SLsockid, SLsockaddr WRITE): &
  SLgetpeername), &
(ROUTINE VOID, INTEGER (SLsockid, INTEGER): &
  SLlisten), &
(ROUTINE VOID, INTEGER (SLsockid, SLsockid WRITE, SLsockaddr): &
  SLaccept), &
(ROUTINE VOID, INTEGER (SLsockid, SLsockaddr): &
  SLconnect), &
(ROUTINE VOID, INTEGER (SLsockid, BYTE POINTER, INTEGER, INTEGER, INTEGER WRITE): &
  SLsend), &


Page 234

The :IMPORT and :DEFS Files

ND-860372.1 EN

(ROUTINE VOID, INTEGER (SLsockid, SLiov POINTER, INTEGER, INTEGER WRITE) : &
SLsendV),&

(ROUTINE VOID, INTEGER (SLsockid, BYTE POINTER, INTEGER, INTEGER, SLin_sockaddr POINTER, &
INTEGER WRITE) : &
SLsendTo),&

(ROUTINE VOID, INTEGER (SLsockid, BYTE POINTER, INTEGER, INTEGER, INTEGER WRITE) : &
SLrecv),&

(ROUTINE VOID, INTEGER (SLsockid, BYTE POINTER, INTEGER, INTEGER, SLin_sockaddr POINTER, &
INTEGER WRITE) : &
SLrecvFrom),&

(ROUTINE VOID, INTEGER (SLsockid, INTEGER WRITE) : &
SLsense),&

(ROUTINE VOID, INTEGER (SLsockid, INTEGER) : &
SLshutdown),&

(ROUTINE VOID, INTEGER (SLsockid) : &
SLclose),&

(ROUTINE VOID, INTEGER (SLsockid, INTEGER, INTEGER WRITE, BYTE POINTER, INTEGER) : &
SLgetOption),&

(ROUTINE VOID, INTEGER (SLsockid, INTEGER, INTEGER, BYTE POINTER, INTEGER) : &
SLsetOption),&

(ROUTINE VOID, INTEGER (SLsockid, INTEGER, SLlocArg POINTER, INTEGER) : &
SLioctl),&

(ROUTINE VOID, INTEGER4 (INTEGER4) : &
SLhtonl),&

(ROUTINE VOID, INTEGER2 (INTEGER2) : &
SLhtons),&

(ROUTINE VOID, INTEGER4 (INTEGER4) : &
SLntohl),&

(ROUTINE VOID, INTEGER2 (INTEGER2) : &
SLntohs),&

(ROUTINE VOID, INTEGER (BYTES, SLinaddr WRITE) : &
SLinNetAddr),&

(ROUTINE VOID, SLhostent POINTER : &
SLgetHent),&

(ROUTINE VOID, VOID (BOOLEAN) : &
SLsetHent),&

(ROUTINE VOID, VOID : &
SLendHent),&

(ROUTINE VOID, SLhostent POINTER (BYTES) : &
SLgHbyName),&

(ROUTINE VOID, SLhostent POINTER (SLinaddr) : &
SLgHbyAddr),&

(ROUTINE VOID, SLnetent POINTER : &
SLgetNent),&

(ROUTINE VOID, VOID (BOOLEAN) : &
SLsetNent),&

Page 235

SINTRAN SLIB Programmers Guide

ND-860372.1 EN

(ROUTINE VOID, VOID : &
  SlnedNent), &
(ROUTINE VOID, SLnetent POINTER (BYTES) : &
  SlgNbyName), &
(ROUTINE VOID, SLnetent POINTER (SLinaddr) : &
  SlgNbyAddr), &
(ROUTINE VOID, SLprotoent POINTER : &
  SlgPent), &
(ROUTINE VOID, VOID (BOOLEAN) : &
  SlsetPent), &
(ROUTINE VOID, VOID : &
  SlendPent), &
(ROUTINE VOID, SLprotoent POINTER (BYTES) : &
  SlgPbyName), &
(ROUTINE VOID, SLprotoent POINTER (INTEGER) : &
  SlgPbyNumber), &
(ROUTINE VOID, SLservent POINTER : &
  SlgetSent), &
(ROUTINE VOID, VOID (BOOLEAN) : &
  SlsetSent), &
(ROUTINE VOID, VOID : &
  SlendSent), &
(ROUTINE VOID, SLservent POINTER (BYTES, BYTES POINTER) : &
  SlgSbyName), &
(ROUTINE VOID, SLservent POINTER (INTEGER, BYTES POINTER) : &
  SlgSbyPort)

$EOF

Page 236

I'm sorry, but the page appears to be blank except for the header and footer information. There's no visible content to transcribe into Markdown.


Page 237

Appendix B

ERROR MESSAGES


Page 238

It seems that the page you provided is blank, except for some details like page number and title.

Here's the Markdown representation:

# Error Messages
ND-860372.1 EN

---

(Note: Since there are no diagrams or additional text, only the visible details are included.)


Page 239

Synopsis

This appendix describes all the error information which SLIB returns, and the error messages which may appear from TCP and IP.

(472xxx)

The first category contains the error messages coming from the Internet Protocol (IP) on the host computer, and they are displayed on the error console.

(473xxx)

The second category contains the error messages coming from the Transmission Control Protocol (TCP). They are displayed on the error console belonging to the host computer.

(474xxx)

The third category contains the error messages coming from the Socket Library (SLIB). They are displayed on the error console belonging to the host computer.


Page 240

IP Error Messages

The following error messages come from the Internet Protocol (IP) and are displayed on the host computer's error console.

Error Code Message
47201B (20097) AIP bad version of IP header, fragment dropped
A host on the network is transmitting an unknown protocol.
47202B (20098) Bad header length in header, fragment dropped
A host on the network is transmitting an IP frame with an illegal header.
47203B (20099) Bad length of incoming data, fragment dropped
A host on the network is transmitting a frame that is too long or too short.
47204B (20100) Bad flag in header, fragment dropped
A host on the network is transmitting an illegal IP frame.
47205B (20101) DF flag, but offset in header, fragment dropped
Inconsistency between offset in frame and do-not-fragment flag.
47206B (20102) Bad offset in header, fragment dropped
After reassemble, the total length will be longer than the maximum allowed.
47207B (20103) Checksum error in IP header, fragment dropped
47210B (20104) Destination is not my IP address, check IP address
This error message may occur if you have changed the IP address on the receiving host.

Page 241

SINTRAN SLIB Programmers Guide

Error Codes

Code Message
47211B (20105) Unknown user protocol, fragment dropped The following protocols are supported: TCP and ICMP.
47212B (20106) Time to live exceeded, fragment dropped
47213B (20107) No more buffers for reassemble, fragment dropped There is no more buffers available in TCP. Reduce the load.
47214B (20108) Unknown options, fragment dropped A host has sent an IP frame with an illegal option field.
47216B (20110) No more buffers for transmit, fragment dropped Number of remote clients using GET or local close.
47223B (20115) PIOCOS error, error code in information field May be hardware failure or noise.
47224B (20116) Fatal error in IOC port message system, error code in information field Error status from IOC PORT message system.
47226B (20118) Fatal error in request, response block
47227B (20119) Medium access dead, reload system Might be a hardware failure.
47231B (20121) IP initialization failed, check cable, hardware
47233B (20123) AIP same IP Two or more hosts have the same Internet address.

Page 242

TCP Error Messages

On the following pages are explanations of the TCP error messages printed on the host computer's error device.

Error Code Description Explanation
47301B (20161) Invalid argument or request An application request with one or more invalid parameters has been issued, or an internal operation was rejected. If caused by inconsistency in TCP, TCP will, if the error is considered fatal, close itself down.
47302B (20162) Protocol not available A request has been issued for a protocol which is not implemented. The current incoming request is ignored.
47303B (20163) Operation not supported on socket Purely internal to TCP and the application.
47304B (20164) Address family not supported Purely internal to TCP and the application.
47305B (20165) Address already in use Purely internal to TCP and the application.
47306B (20166) Cannot assign requested address Purely internal to TCP and the application.
47307B (20167) Network is down TCP either failed to establish contact or has lost its contact with the underlying communication subsystem. Considered a fatal error - TCP will close itself down.

Page 243

SINTRAN SLI B Programmers Guide

Network Issues and Codes

Code Description Additional Information
47310B (20168) Network dropped connection on reset Purely internal to TCP and the application.
47311B (20169) Software caused connection abort Purely internal to TCP and the application.
47312B (20170) No buffer space available There is currently no free buffer in TCP. If this occurs, TCP will, if possible, drop incoming segments to release one or more buffers. If enough space is still not available, TCP will be suspended until a buffer is available.
47313B (20171) Socket is already connected Purely internal to TCP and the application.
47314B (20172) Connection timed out Purely internal to TCP and the application.
47315B (20173) Connection refused Purely internal to TCP and the application.
47316B (20174) Operation would block Purely internal to TCP and the application.
47317B (20175) Error in checksum A corrupted segment has been received. A checksum is provided on each segment sent and received. If there is an error in the checksum, the incoming segment is ignored.

Page 244

Error Messages

47320 (20176)

No successful wakeup of user

An application is temporarily (or permanently) not available. A message buffer (request or response) being sent to the user was not sent, due to lack of resources in the underlying communication subsystem.

47321B (20177)

Illegal data length

Illegal buffer received from user or AIP. The buffer length is greater than the maximum length accepted. Inconsistency in the user application or in AIP.

47322B (20178)

Not returned letter from AIP

Error not in use (obsolete).

47323B (20179)

CompareNames failed

Error not in use (obsolete).

47324B (20180)

No contact with AIP

Error not in use (obsolete).

47325B (29181)

Attach request failed

Error not in use (obsolete).

47326B (20182)

Buffer already free

Double chaining attempted. An attempt was made to release an already released buffer. TCP's tables and/or code can have been overwritten. However, not considered as a fatal error. TCP will not close itself down.


Page 245

SINTRAN SLIB Programmers Guide

ND-860372.1 EN

Error Codes and Descriptions

Error Code (ID) Description
47327B (20183) Retrieving used buffer
Inconsistency in buffer allocation. An attempt was made to reserve a buffer already in use. TCP's tables and/or code have been overwritten. Considered a fatal error - TCP will close itself down.
47330B (20184) Illegal user request
Purely internal to TCP and the application.
47331B (20185) Illegal magic number
Error not in use (obsolete).
47332B (20186) Error in flushing buffer
Buffer queue-length inconsistency. Failed to release a chain of buffers, or an attempt was made to drop more data than existed. However, not considered a fatal error - TCP will not close itself down.
47333B (20187) Lost SLIB access point
A request or response from a user has been received, but the user (socket) is not active in TCP (i.e. the specified connection identifier is not a valid identifier).
47334B (20188) Illegal header length
Illegal buffer received from user or AIP. The buffer length is less than the minimum header required, i.e. buffer is too short. Inconsistency in the user application, AIP or in the remote system.
47335B (20189) Lost header-info on connection
Failed to send a segment. The buffer containing the information is not available - the buffer has already been released. Inconsistency in TCP's buffer allocation. However, since this only affects one, single connection, it is not considered fatal.

Page 246

Error Messages

47336B (20190)

Receive space full

Error not (yet) used.

47337B (20191)

No more users allowed

The maximum number of users are already attached to TCP. Each user allocates resources in TCP, and currently there are no free resources.

47340B (20192)

No receive queue

Not able to send data to the user. TCP's tables and/or code can have been overwritten. However, not considered as a fatal error - TCP will not close itself down.

47341B (20193)

Invalid TCP state transition

The current event and/or request is ignored. Inconsistency in TCP. However, not considered a fatal error - TCP will not close itself down.

47342B (20194)

User sendqueue full

Purely internal to TCP and the application.

47343B (20195)

Error in underlying subsystem

If there is an unexpected error from any of the underlying subsystems, this is reported. Such an error can be caused by memory overwrite (tables and/or code destroyed), or temporary lack of resources (e.g., messages, buffers, ports etc.), or by fatal errors in the underlying communication system. Depending on the error and the current state, the error is either considered as ignorable (recoverable situation) or as fatal (cannot recover). If fatal, TCP will close itself down.


Page 247

SINTRAN SLIB Programmers Guide

Error Codes

47344B (20196) - TCP Initialization Failed

In the startup sequence, all errors are considered fatal errors. If not loaded correctly, or if an error from the operating system, or if an error from the underlying communication system, TCP will close itself down.

47345B (20197) - No Access to User

A message buffer (request or response) being sent from TCP to the user returned to TCP as a non-delivery message, due to overload.

47346B (20198) - User is Not Running

Previously active user (e.g. a client or a server program) has stopped (abnormal termination). When TCP detects that the user has aborted, it will release all resources associated with that user.


Page 248

SLIB Error Messages

On the following pages is a list of the error messages coming from SLIB. Each error is described in the following way:

Octal value (decimal value) Constant Error message

Explanation:

Where:

  • Value is
    The error status retrieved by SLIB routines.
  • Constant is
    The PLANC constant used to define the error in the SLIB:DEFS file which can be used to program around error situations.
  • Error message is
    A one line summary of the error for reference. It is the same as the one you will get if you are using User Environment Library routines.
  • Explanation is
    A detailed description of the error, explaining what has happened, and what you can do to solve the problem.

Page 249

SINTRAN SLIB Programmers Guide

Error Codes and Explanations

Error Code Identifier Description Explanation
47401B SLEwksz Work size area The size of the work area is not large enough. The application will stop. Check that the parameter SLSzWorkArea is correctly calculated.
47402B SLEptr Pointer error Error not in use (obsolete).
47403B SLEilsid Illegal socket ID The socket has been disconnected.
47404B SLElostPL Lost contact with PL (packet level) The application has no more contact with TCP. TCP might have stopped.
47405B SLEconstart Error when establishing contact with PL It is impossible to attach to TCP. This error may occur if TCP did not start, or if your application tries to establish contact with an undefined TCP device.
47406B SLEnospace No more space Currently no free resources (e.g. socket messages). All resources are in use.
47407B SLEnospinmsg Too little space in message Error not in use (obsolete).
47410B SLEslibfatal Fatal internal SLIB error Fatal internal error.
47411B SLEtryagain Used between SLIB and protocols Error used between SLIB and protocols.

Page 250

Error Messages

47412B (20234)

SLEinval:
Argument invalid
Explanation:
The application is sending a request to SLIB with one or more invalid arguments.

47413B (20235)

SLEprototype:
Protocol wrong type for socket
Explanation:
Request for a type of socket for which there is no supporting protocol.

47414B (20236)

SLEnoprotoopt:
Bad protocol option
Explanation:
A request has been issued for a protocol which is not implemented.

47415B (20237)

SLEprotonosupport:
Protocol not supported
Explanation:
A request has been issued for a protocol which is not implemented. For a socket request, neither the socket type nor the socket protocol matched a supported protocol.

47416B (20238)

SLEsocktnosupport:
Socket type not supported

47417B (20239)

SLEaddrinuse:
Address already in use
Explanation:
The Internet Network address is already used by another socket application. This is returned by a socket call when an already existing socket is using the same (UDP/TCP) port number. This condition is often transient, because once a connection is established the local address can be reused. Either wait for the socket to become available or retry, specifying a different port.

47420B (20240)

SLEaddrnotavail:
Cannot assign requested address
Explanation:
Invalid Inter Network address. Cannot assign requested address. An invalid network number may have been specified in a socket request.


Page 251

SINTRAN SLIB Programmer's Guide

Network Errors

47421B (20241)

SLEnetdown: Network is down

47422B (20242)

SLEnetunreach: Network is unreachable, FATAL

Explanation:
Network is unreachable. A connect or send request has been given, but there is no known route to the remote host.

47423B (20243)

SLEnetreset: Network dropped connection on reset

Explanation:
Network dropped connection on reset.

47424B (20244)

SLEconnaborted: Software caused connection abort

Explanation:
Software caused connection abort. Something probably went wrong at the remote end of the connection and the local system detected it (TCP only).

47425B (20245)

SLEconnreset: Connection reset by peer

Explanation:
Connection reset by peer. Something probably went wrong at the remote end of the connection and the remote system detected it (TCP only).

47426B (20246)

SLEisconn: Socket is already connected

Explanation:
Socket is already connected. This is a response to a connect request that attempts to connect to an already connected socket.

47427B (20247)

SLEnotconn: Socket is not connected

Explanation:
Socket is not connected. A write or read request was attempted on a socket that had not been connected.

47430B (20248)

SLEshutdown: Cannot send after shutdown

Explanation:
Cannot send after socket shutdown. The socket is already closed, so nothing can be sent to it.


Page 252

Error Messages

ND-860372.1 EN


Error Code 47431B (20249)

SLEtimedout:
Connection timed out

Explanation:
Connection timed out. No response was received from the remote system. Either the remote system is not functioning or there is an addressing problem.

Error Code 47432B (20250)

SLEconnrefused:
Connection refused

Explanation:
Connection refused. The remote system did not issue an accept call for a connection request.

Error Code 47433B (20251)

SLEnobufs:
No buffer space available

Explanation:
Subsystem message space full, subsystem task message space limit.

Error Code 47434B (20252)

SLEunexpected:
Unexpected subsystem error

Error Code 47435B (20253)

SLEwouldblock:
Operation would block.

Explanation:
An I/O operation that normally would have blocked (such as SLrecv, SLsend or SLaccept) cannot block, because the SLiocNBIO option has been set by the SLioctl call, and thus cannot complete immediately, because non-blocking I/O is in effect. No data are transferred, and the I/O operation may be attempted again until the I/O actually occurs.



Page 253

Index

A

Topic Page(s)
Accept connections 17, 18
Acknowledgement of packets 21
Activation/deactivation task mechanism 39
actualEvents parameter 41
Address structure 12
AIP-HOSTS:SYMB example 88
AIP-HOSTS:SYMB file 87
AIP-NETWORKS:SYMB example 90
AIP-NETWORKS:SYMB file 89
AIP-PROTOCOLS:SYMB example 91
AIP-PROTOCOLS:SYMB file 90
AIP-SERVICES:SYMB example 92
AIP-SERVICES:SYMB file 91
Alias name 87
Alias names 89, 90, 91
ARPANET 3
Associating data to the tasks 35

B

Topic Page(s)
Backlog 18
Bind call 17

C

Topic Page(s)
Client example 108
Client mode file 116
Close a socket 20
Communication domain 11, 15
Connect 18
Control I/O 57
Create socket 15, 22
Create tasks 32

D

Topic Page(s)
DARPA 12
Datagram socket 11, 21
Deactivation task mechanism 39
Domain 15
Duplicated messages 21

E

Topic Page(s)
Error messages from IP 230
Error messages from SLIB 238

Page 254

Technical Contents

Error Messages from TCP

  • Error Messages from TCP ................................................... 232

Error SL EaddrInUse

  • Error SLEaddrInUse ............................................................. 55

Event System

  • Event system .............................................................................. 137
  • Events ......................................................................................... 41, 137
  • External events .............................................................................. 41, 42

G

  • Get active connections ................................................................. 61, 137
  • Get mbuf statistics ......................................................................... 69
  • Get Network statistics ................................................................. 72
  • Get no activity timer ..................................................................... 57, 137

H

  • Hardware statistics ......................................................................... 66
  • Host name database ..................................................................... 87

I

  • I/O control ...................................................................................... 42, 55, 137
  • ICMP .............................................................................................. 4
  • ICMP description ........................................................................... 73
  • Initialize SLIB .................................................................................. 15, 27, 134
  • InitParam parameter description .................................................. 28, 134
  • Internet address ............................................................................. 12, 87
  • Internet address binding ............................................................... 48
  • Internet domain .............................................................................. 12, 15
  • Internet Message Protocol ............................................................. 4
  • Internet protocol ............................................................................ 4
  • Internet Protocol Number .............................................................. 16
  • Internet protocol number example ................................................ 16
  • IP ..................................................................................................... 4
  • IP description .................................................................................. 73
  • IP error messages ........................................................................... 230

L

  • Linking an application using %SLIB$ ............................................ 116
  • Linking an application using SLIB ................................................. 6, 107

M

  • Maintask ......................................................................................... 32
  • max_AUserDatap, SLmaxima record parameter ............................. 29
  • Max_AUserDatap, SLmaxima record parameter ............................ 134
  • max_debfld, SLmaxima record parameter ..................................... 29
  • Max_debfld, SLmaxima record parameter ..................................... 134
  • max_debug, SLmaxima record parameter ..................................... 29
  • Max_debug, SLmaxima record parameter ..................................... 134
  • Max_nballocmsg, SLmaxima record parameter ............................ 134

Page 255

Parameters

M

  • max_nballocmsg, SLmaxima record parameter ............................................ 29
  • max_nports, SLmaxima record parameter ................................................ 28
  • Max_nports, SLmaxima record parameter ............................................... 134
  • max_nsallocmsg, SLmaxima record parameter ........................................ 29
  • Max_nsallocmsg, SLmaxima record parameter ....................................... 134
  • max_nsockets, SLmaxima record parameter .......................................... 28
  • Max_nsockets, SLmaxima record parameter ........................................... 134
  • max_tcpdev, SLmaxima record parameter .............................................. 29
  • Max_tcpdev, SLmaxima record parameter ............................................. 134
  • mbuf statistics ............................................................................................ 69
  • Mbuf statistics ............................................................................................ 137, 186, 194
  • Mode file for client ................................................................................... 116
  • Mode file for server .................................................................................. 107
  • Multitasking ............................................................................................. 31

N

  • Network address ...................................................................................... 87
  • Network number ...................................................................................... 89
  • Network statistics ..................................................................................... 72, 182, 190
  • No activity timer ...................................................................................... 57, 137
  • Nonblocking option ................................................................................ 56

O

  • Official host name ................................................................................... 87
  • Official network name ............................................................................. 89
  • Official protocol name ............................................................................ 90
  • Official service name ............................................................................... 91
  • Own events .............................................................................................. 41, 43, 153

P

  • Parameter initParam ................................................................................ 28
  • Parameter Task ......................................................................................... 31
  • parameter TaskDataP ............................................................................. 31
  • Parameter TaskStackSize ....................................................................... 31
  • Parameter WorkAreaP ........................................................................... 27
  • Port number ............................................................................................. 12, 52, 91
  • Protocol name ......................................................................................... 91
  • Protocol number ...................................................................................... 90
  • Protocols .................................................................................................. 16

R

  • Raw socket ............................................................................................... 11
  • Receive connections ................................................................................ 32
  • Reserve messages ................................................................................... 29
  • Reuse socket address .............................................................................. 52, 151
  • Routine SLioctl ........................................................................................ 55

Page 256

Technical Page Index

Topic Page Number(s)
Select a default TCP device 30
Select a specific TCP device 30
Select TCP device 29
Send data 22
Server example 97
Service establishment 15
Set an event bit on a socket 60
Set no activity timer 57, 137
Set socket event 42
Setting an event to a socket 42
Shutdown 20, 154
Signal remote peer 57
Signal the application 58
SLaccept 18, 120
SLbind 17, 22, 122
SLclose 20, 124
SLconnect 18, 23, 125
SLEaddrInUse, error 55
Sleep 21, 156
Sleep on events 21
SLexit 31, 127
SLfork 31, 128
SLgetOption 129
SLgetpeermame 17, 132
SLgetsockname 17, 133
SLIB 5
SLIB error messages 238
SLIB:DEFS 6
SLIB:DEFS file 211
SLIB:IMPT 6
SLIB:IMPT file 223
SLinit 15, 27, 31, 32, 134
SLiocActConn 61
SLiocArpTable, record description 77
SLiocGArptable, SLioctl request 77
SLiocGenInfo, record description 78
SLiocGHwStat, SLioctl request 69
SLiocGload, SLioctl request 82
SLiocGMbStat, SLioctl request 69
SLiocGmbstat, SLioctl request 71
SLiocGNetwork, SLioctl request 76
SLiocGNOACT, SLioctl request 57
SLiocInt 59
SLiocKill, SLioctl request 83
SLiocMbStat, record description 70

Page 257

Index

Topic Page Numbers
SLiocNBIO, SLioctl request 56
SLiocNetwork, record description 72
SLiocSNOACT SLioctl request 57
SLiocSOEV, SLioctl request 42, 60
SLioctl 42, 55, 61, 137
SLioctl routine 55
SListen 18, 139
SLMainTaskStackSize constant 28
SLMaxFork constant 28
SLMaxPorts constant 28
SLMaxSockets constant 28
SLock 15
SLotherEvent 42
SLotherevent 141
SLrecv 19, 142
SLrecvFrom 23
SLrevFrom 144
SLsend 19, 146
SLsendTo 22, 148
SLsense 21, 150
SLsetOption 54, 151
SLSetOwnEvent 45
SLSetOwnEvents 153
SLshutdown 20, 154
SLsleep 21, 156
SLsocket 15, 22, 158
SLSubTaskStackSize constant 28
SLszWorkArea constant 27
so_reuseaddr, SLsetoption option 54
Socket 11
Socket address 12
Socket creation 15, 22
Socket event 41, 137
Socket ID 12
Socket Library 5
Standard Internet protocols 4
Status TCP connection 62
Stream socket 11
Subtask 32
Suspend application 21
Synchronize tasks 43

T

Table Page Numbers
Table, AIP-HOSTS:SYMB file 88
Table, AIP-NETWORKS:SYMB file 90
Table, AIP-PROTOCOLS:SYMB file 91
Table, AIP-SERVICES:SYMB file 92
Table, FTP client 177

Page 258

Index

T

  • Table, Internet protocol number .................................. 16
  • Table, mbuf types ........................................................... 70
  • Table, SLiocCTL Functions .......................................... 56
  • Table, SLiocCTL functions .......................................... 137
  • Table, Socket Address Structure ................................ 12
  • Table, Socket type ......................................................... 16
  • Table, TCP devices ....................................................... 30
  • Table, TCP state .......................................................... 65
  • Task parameter .............................................................. 31
  • Task synchronization ................................................. 43
  • TaskDataP parameter .................................................. 31
  • Tasks create .................................................................. 32
  • TaskStackSize parameter ........................................... 31
  • TCP ................................................................................. 4
  • TCP connection status ................................................. 62
  • TCP description .......................................................... 73
  • TCP device .................................................................... 29
  • TCP Error Messages .................................................. 232
  • Transmission Control Protocol ............................... 4

U

  • UDP ................................................................................ 4
  • UDP description .......................................................... 73
  • User Datagram Protocol ............................................. 4

W

  • Wake up events ............................................................ 41
  • WorkAreaP parameter ................................................ 27

Page 259

I'm unable to convert text from a blank or unreadable document. Can you provide a clearer image or another page?


Page 260

[Image: Cover with colored squares]