IPX/SPX Programming Manual
Programming Using the Socket Interface
HP NonStop IPX/SPX Programming Manual—528022-001
3-6
Basic Steps for Programs
Connecting a Socket
The connect function associates a remote address and port number with the socket.
For SPXII, connect issues a request for an active connection. For IPX, no active
connection exists. The connect call serves as a means to permanently specify the
remote address and port number (or protocol number) so that each call to transfer data
does not need to specify this information. For IPX, your program can either call
connect to specify the remote address and port/protocol number once, or the
program can use the sendto or recvfrom routines.
Transferring Data
Two sets of function calls are provided for sending and receiving data. One set, the
send and recv function calls, uses the remote address and port number specified for
the socket in a previous call to connect. The other set, the sendto and recvfrom
function calls, uses the remote address and port number passed as an argument in the
call. The sendto and recvfrom function calls are provided for use with
connectionless protocols (IPX) in programs that do not call connect.
Shutting Down and Closing a Socket
The shutdown function call shuts down data transfer on an actively connected SPXII
socket, either partially or completely (preventing further reads, writes, or both). Calling
shutdown is optional. If a program does not call shutdown, a call to the Guardian
FILE_CLOSE procedure performs the shutdown procedure. Because shutdown
applies to an active connection, a program using IPX sockets does not use this
function call.
When communication is complete, your program must close the socket explicitly with a
call to FILE_CLOSE_ or CLOSE.
Server Program
The basic steps performed by a server program include the following:
1. Designate the NonStop IPX/SPX process name (optional).
2. Create a socket.
3. Bind the socket to an IPX address.
4. Execute the SAP_OPEN function to allow access to the SAP table.
5. Listen for connections (required for SPXII; not needed for IPX).
6. Choose a service name and service type. Call the SAP_START function to start
service advertising.
7. Accept incoming connections. When a connection is received, create a new socket
and accept the connection on the new socket (required for SPXII; not needed for
IPX).