TCP/IP Programming Manual

Alternatively, for NonStop TCP/IP, you can use LNP to create multiple TCP6SAM processes,
each with its own IP address, similar to the multiple- TCP/IP process technique of conventional
TCP/IP. (See Multiple NonStop TCP/IP Processes and Logical Network Partitioning (LNP)
(NonStop TCP/IPv6, H-Series and G06.22 and Later G-Series RVUs Only) (page 43).)
TCP Port Considerations for NonStop TCP/IP and NonStop TCP/IP. If you have used the following
DEFINE to set up round-robin filtering for Parallel Library TCP/IP or NonStop TCP/IPv6, consider
the following for socket programming.
ADD DEFINE =PTCPIP^FILTER^KEY, class map, file file-name
Round-robin filtering allows multiple binds to the same IP and port if more than one application
per processor is binding to the port at one time. Furthermore, the multiple binds to the same
IP port can only come from processes that share the same NonStop TCP/IP or Parallel Library
TCP/IP filter key (the variable file name in the DEFINE).
You can limit the shared ports by adding one or both of the following defines:
ADD DEFINE =PTCPIP^FILTER^TCP^PORTS, FILE P/Pendport
ADD DEFINE =PTCPIP^FILTER^UDP^PORTS, FILE Pstartport.Pendport
The startport and endport variables are integers specifying the allowable port range.
The =PTCPIP^FILTER^TCP^PORTS key limits the shared TCP ports to the range defined in
startport and endport. The =PTCPIP^FILTER^UDP^PORTS key limits the shared UDP
ports to the range defined in startport and endport. Ports outside those ranges are not
shared.
See the TCP/IPv6 Configuration and Management Manual for more information about DEFINE.
See Nowait Call Errors (page 86) for information on error checking.
Declare the address_ptr variable as struct sockaddr_in6 * for IPv6 use or as struct
sockaddr_storage * for protocol-independent use. In C, when you make the call, cast
the variable to sockaddr. (See the IPv6 example.)
Examples
INET: the following IPv4 programming example calls the bind routine. The socket fd is bound to
the address and port number in the sin structure:
#include <socket.h>
#include <in.h>
#include <netdb.h>
...
struct sockaddr_in sin;
...
/* The code here (not shown) should create a socket fd.
* Then the local address and port number
* in the sin structure are set up. The port number is passed
* as an argument when the program is run.
*/
sin.sin_family = AF_INET;
sin.sin_addr.s_addr = INADDR_ANY;
sin.sin_port = port;
if (bind (fd, (struct sockaddr *)&sin, sizeof (sin)) < 0) {
perror ("SERVER: Bind failed.");
exit (1);
}
/* Bind call succeeded. /*
INET6: the following IPv6 programming example calls the bind routine. The socket fd is bound
to the address and port number in the sin structure:
#include <socket.h>
#include <in.h>
#include <in6.h>
bind, bind_nw 101