OSI/AS and OSI/TS Supplement (Includes RFC-1006 Support)
Programming a Server
Programming With the Sockets Interface
107751 Tandem Computers Incorporated 7–3
2. Create a socket.
The call to SOCKET_NW creates a socket. As part of its operation, it calls the
OPEN procedure to open a file for interprocess communication. The socket
number it returns actually is the file number obtained from OPEN.
3. Bind the socket to a local well-known server port and the local IP address.
The server calls BIND_NW to permanently associate the socket with the local well-
known port. The well-known port 102 has been reserved for ISO TSAP service.
In RFC-1006, the transport responder calls BIND_NW with the well-known port
102. The local IP address is required.
4. Set the maximum queue length of pending TCP incoming connections by calling
LISTEN.
In the Tandem socket library environment, a LISTEN socket call only sets the
maximum queue length of pending TCP incoming connections. It does not
perform a PASSIVE OPEN.
5. Listen and accept the connection.
5a. To check for (await) an incoming connection on the socket (perform a PASSIVE
OPEN), call ACCEPT_NW. The remote client port number and the remote IP
address from which the connection was initiated will be returned with the call.
5b. When the connection is really received (connected), create a new socket.
5c. Eventually accept the connection on the new created socket by calling
ACCEPT_NW2 with the remote client port number and the remote IP address
returned from the ACCEPT_NW call.
A server uses one socket to check for (await) incoming connections and another
socket for data transfer. In other words, the server can check for a new connection
on the first socket, and when the connection has really been received, eventually it
accepts the connection on a second created socket. This mechanism is performed
by a sequence of three calls : ACCEPT_NW on the first socket, SOCKET_NW to
create a new socket, and ACCEP_NW2 on the new socket.
The second socket then can start data transfer. The server still can await another
new incoming connection on the first socket by calling ACCEPT_NW again.
Therefore, after establishing the first TCP connection, to listen on the same IP
address, the TSP responder only needs to repeat steps 5a, 5b, and 5c to accept new
incoming connections.
6. Start data transfer on the new socket created in step 5b.
For sending and receiving data, use SEND_NW and RECV_NW calls on the new
socket created in step 5b.
7. Shut down the socket created in step 5b (optional).
The SHUTDOWN_NW call shuts down data transfer on the actively connected
TCP socket, either partially or completely (preventing further reads, writes, or