IPX/SPX Programming Manual
Programming Using the Socket Interface
HP NonStop IPX/SPX Programming Manual—528022-001
3-7
Basic Steps for Programs
8. Start data transfer (if step 5 was done, use the new socket created in that step).
9. Shut down the socket (optional for SPXII; not done for IPX). For SPXII only, call
shutdown or FILE_CLOSE.
10. Close the socket.
For servers, some of the calls or call requirements vary depending on the way the
server operates. Servers that operate at a well-known port (one that is associated with
a specific service provided by the server) must perform a call to bind to permanently
associate the socket with that port.
Steps 1, 2, 4, and 8 through 10 are used in the same way by servers and clients. See
for a list of the steps that are similar. The steps for listening for and accepting
connections apply only to servers. These steps are described as follows.
Binding a Socket
A program can associate the socket with a local address and port number by calling
the bind function. This call is not recommended for client programs, because it
increases process protocol overhead. If the program does not call bind, the connect
function performs the binding.
For IPX, calls to bind and connect are unnecessary because IPX datagrams contain
all the addressing information needed.
Listening for Connections
The listen function call is provided in the 4.3 BSD UNIX operating system to set the
queue length for pending SPXII connections on a socket. Although in the NonStop
Kernel the queue length is fixed at five, the listen function call is used internally by
the socket calls. SPXII servers must call listen before accepting a connection.
Accepting a Connection
A server typically uses one socket to check for connections and another socket to
transfer data (if the same process performs both functions). This technique allows the
server to check for a new connection on the first socket, accept the new connection,
and start data transfer on a second socket. The server can then check for another new
connection on the first socket without waiting for the data transfer to complete. The
accept function call is designed for this type of operation.
IPX servers should not call accept. A server using IPX sockets can call connect to
specify the remote address and port, and then transfer data with recv and send calls.
The server can omit connect and transfer data with recvfrom and sendto calls,
specifying the remote address and port each time data is sent.
The accept function call performs three steps:
1. Checks for connections on an existing socket.
2. Creates a new socket for the data transfer when a connection request arrives.