HP NonStop TCP/IP Programming Manual HP Part Number: 524521-020 Published: March 2014 Edition: J06.04 and subsequent J-sries RVUs, H06.03 and subsequent H-series RVUs, G06.00 and subsequent G-series RVUs, D40.
© Copyright 2010, 2014 Hewlett-Packard Development Company, L.P. Confidential computer software. Valid license from HP required for possession, use or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor’s standard commercial license. The information contained herein is subject to change without notice.
Contents About This Document...................................................................................11 Supported Release Version Updates (RVUs)................................................................................11 Intended Audience..................................................................................................................11 New and changed information for March 2014 (524521-020)......................................................
Programmatic Interface to Raw Sockets......................................................................................41 Programming Considerations...................................................................................................43 Process Names..................................................................................................................43 Multiple NonStop TCP/IP Processes and Logical Network Partitioning (LNP) (NonStop TCP/IPv6, H-Series and G06.
Interfacing TAL Programs to the Socket Library ...........................................................................86 Procedure Prototypes..........................................................................................................87 Implications of the C Socket Library......................................................................................87 Usage/Bind Considerations................................................................................................
Example.........................................................................................................................113 Usage Guidelines............................................................................................................113 gethostid.............................................................................................................................113 Errors............................................................................................................
Examples........................................................................................................................132 if_nameindex.......................................................................................................................132 Errors.............................................................................................................................133 Usage Guidelines..............................................................................................
Errors.............................................................................................................................150 Example.........................................................................................................................150 Usage Guidelines............................................................................................................150 lwres_getnameinfo....................................................................................................
Example.........................................................................................................................175 send_nw2_64_....................................................................................................................175 Errors.............................................................................................................................176 Usage Guidelines.................................................................................................
t_recvfrom_nw......................................................................................................................201 Errors.............................................................................................................................202 Usage Guidelines............................................................................................................202 t_recvfrom_nw64_..................................................................................................
About This Document This manual describes application development for the NonStop TCP/IP, Parallel Library TCP/IP, NonStop TCP/IPv6, and CIP subsystems using the HP Guardian socket library routines. Supported Release Version Updates (RVUs) TCP/IP: D40.00 and all subsequent D-series RVUs, G06.00 and all subsequent G-Series RVUs, and H06.03 and all subsequent H-series RVUs until otherwise indicated by its replacement publication Parallel Library TCP/IP: G06.
recvfrom64_ (page 160), t_sendto_nw64_, t_recvfrom_nw64_ (page 203) and sendto_nw64_ (page 182). • Changed the data type of length parameters to socklen_t in inet_ntop, getnameinfo, gethostname, gethostname, lwres_getipnodebyaddr and lwres_getnameinfo APIs. New and changed information for August 2011 (524521-016) This edition of the manual includes the following changes: • Added hostname and IP address resolution in the “Domain Name Resolution” (page 26) section.
Other changes include: • Descriptions of the “t_recvfrom_nw” (page 201) and “t_sendto_nw” (page 204) socket routines, removed in an earlier edition, have been restored. • The description of “sock_close_reuse_nw” (page 190) has been updated to describe error 4123. • IPV6_V6ONLY has been added to the descriptions of the “getsockopt, getsockopt_nw” (page 128) and “setsockopt, setsockopt_nw” (page 184) routines.
In addition, the following corrections were made: • Sample programs were modified to show Include statements. • TAL syntax diagrams were updated to show INT(32) declarations instead of INT since the WIDE model is more frequently used. • The description of inet_ntop inTable 13 (page 83) was corrected. • There was a correction to the code example for freeaddrinfo (page 104). • Since you no longer have to define the SRL before starting the TCP6SAM process (as of G06.
• Sample TCP/IP programs have been moved to this manual from the TCP/IP and IPX/SPX Programming Manual in Chapter 5 (page 208). • Other minor changes have been made to the manual to incorporate the Parallel Library TCP/IP subsystem. G06.22 RVU Update (December 2003, 524521-002) • Information about using sockets in both the conventional NonStop TCP/IP and NonStop TCP/IPv6 environments has been added. (See Using NonStop TCP/IP and NonStop TCP/IPv6 or Parallel Library TCP/IP (page 24).
Notation Conventions General Syntax Notation This list summarizes the notation conventions for syntax presentation in this manual. UPPERCASE LETTERS Uppercase letters indicate keywords and reserved words. Type these items exactly as shown. Items not enclosed in brackets are required. For example: MAXATTACH Italic Letters Italic letters, regardless of font, indicate variable items that you supply. Items not enclosed in brackets are required.
{ } Braces A group of items enclosed in braces is a list from which you are required to choose one item. The items in the list can be arranged either vertically, with aligned braces on each side of the list, or horizontally, enclosed in a pair of braces and separated by vertical lines. For example: LISTOPENS PROCESS { $appl-mgr-name } { $process-name } ALLOWSU { ON | OFF } | Vertical Line A vertical line separates alternatives in a horizontal list that is enclosed in brackets or braces.
!i and !o In procedure calls, the !i notation follows an input parameter (one that passes data to the called procedure); the !o notation follows an output parameter (one that returns data to the calling program). For example: CALL CHECKRESIZESEGMENT ( segment-id , error ) ; !i !o !i,o In procedure calls, the !i,o notation follows an input/output parameter (one that both passes data to the called procedure and returns data to the calling program).
A group of items enclosed in brackets is a list of all possible items that can be displayed, of which one or none might actually be displayed. The items in the list can be arranged either vertically, with aligned brackets on each side of the list, or horizontally, enclosed in a pair of brackets and separated by vertical lines.
UPPERCASE LETTERS Uppercase letters indicate names from definition files. Type these names exactly as shown. For example: ZCOM-TKN-SUBJ-SERV lowercase letters Words in lowercase letters are words that are part of the notation, including Data Definition Language (DDL) keywords. For example: token-type !r The !r notation following a token or field name indicates that the token or field is required. For example: ZCOM-TKN-OBJNAME token-type ZSPI-TYP-STRING.
• The Guardian Programmer’s Guide describes how to program in the NonStop operating system environment. • The Guardian Procedure Calls Reference Manual lists the syntax and semantics of the NonStop system procedure calls whose functions are not available in the HP C language. • The Guardian Procedure Errors and Messages Manual describes the Guardian messages for NonStop systems that use the NonStop operating system.
Internet Society or other Internet organizations, except as needed for the purpose of developing Internet standards in which case the procedures for copyrights defined in the Internet Standards process must be followed, or as required to translate it into languages other than English.
1 Introduction to Programming to the Guardian Sockets Library This section discusses topics relating to sockets programming in the Guardian environment, including: • “NonStop TCP/IP Subsystems and the Guardian Sockets Application Program Interface (API)” (page 23) • “TCP/IP Programming Fundamentals” (page 24) • “Programming Using the Guardian Sockets Interface” (page 32) • “Basic Steps for Programs” (page 35) • “Programmatic Interface to Raw Sockets” (page 41) • “Programming Considerations” (page
CIP can coexist with NonStop TCP/IPv6 and conventional NonStop TCP/IP on the same system but not with Parallel Library TCP/IP since Parallel Library TCP/IP is not supported on J-series RVUs. CIP also supports IPv6. CIP architecture differs from that of NonStop TCP/IPv6 and conventional NonStop TCP/IP; these differences affect the sockets API. For details about the CIP architecture and application compatibility, see the Cluster I/O Protocols (CIP) Configuration and Management Manual.
Types of Service Depending on the type of communications service required, your application uses one or more of the following protocols: • The Transmission Control Protocol (TCP) provides reliable end-to-end data transfer. TCP is a stream-oriented protocol that has no concept of packet boundaries. TCP guarantees that all data sent is received and that the data arrives in the same order in which it was sent. • The User Datagram Protocol (UDP) provides unreliable datagram service.
requester-server model—that is, a client is the same as a requester. Programming Using the Guardian Sockets Interface (page 32), explains how to develop client and server programs that use sockets. Stream-Oriented Protocol Considerations Unlike a protocol that sends and receives blocks or buffers of packets at a time, TCP is a stream-oriented protocol. The data has no boundaries except those put there by applications using TCP/IP.
Also, see Using the DEFINE Command (page 29) for more information about setting file names and process names. Your program calls gethostbyname and getaddrinfo routines to get the hostname and IP addresses. Guardian socket library gets the hostname and IP addresses as follows: 1. If there is a DEFINE for =TCPIP^HOST^FILE, and if hostname is found, it is returned from this file. If =TCPIP^HOST^FILE is not defined, DNS is queried for the hostname. If hostname is found, it is returned.
The NonStop server socket library uses the DEFINE command to resolve the file names and process names used by the socket library. See Using the DEFINE Command (page 29), for more information about the DEFINE command. When a program sends a name-resolution request to the resolver, the resolver tries to send the query to the servers listed in the RESCONF file, sending the request to the server that has the highest priority first.
in a previous ADD DEFINE command that defines a value for =TCPIP^HOST^FILE or =TCPIP^NODE^FILE. The socket library uses the DEFINE command to resolve the file names and process names used by the socket library. For more information, see Using the DEFINE Command (page 29). ND6HOSTD Process for NonStop TCP/IPv6 The ND6HOSTD process for NonStop TCP/IPv6 is a utility process that you can run to receive and process router advertisement (RA) packets and update the global address information in the DNS.
=TCPIP^PROCESS^NAME Specifies the name of the NonStop TCP/IP process or TCPSAM or TCP6SAM process name =CIP^COMPAT^ERROR,FILE SUPPRESS When set with a file name of “SUPPRESS”, specifies that when an application starts, socket calls that try to invoke a behavior allowed in a previous implementation, but not in CIP, return as if successful even though the behavior did not occur as expected.
LISTNER Process The LISTNER process functions as a “super server” for some application servers provided by HP (such as the FTP server). LISTNER invokes the appropriate NonStop server as connection requests for services are received on well-known TCP ports (in the default configuration). These services do not apply to UDP ports. The use of a single super server—in this case, the LISTNER process—to invoke several other servers, effectively reduces the load on the system.
Generally, at least one end of the session requests a port number that is guaranteed to be unique. The client program normally requests the unique port number, because the server typically uses a well-known port. Network and Host Order In the descriptions of some of the support routines in the socket library, this manual refers to IP addresses or port numbers as being in network order or in host order.
exceptions to this rule are accept_nw2, recvfrom_nw, recvfrom_nw64_,send_nw2, send_nw2_64_, sendto_nw, sendto_nw64_, t_recvfrom_nw, t_recvfrom_nw64_, t_sendto_nw and t_sendto_nw64_, which have different sets of parameters. In addition, a nowait I/O operation is never performed synchronously, and the error EWOULDBLOCK is never returned. After performing a nowait I/O operation, your program must check for completion by issuing a call to the AWAITIOX or FILE_AWAITIO64_ procedure call.
• Because of differences between the UNIX and NonStop operating system I/O environments, some differences exist in the errors returned in errno by the socket routines. Although errors that have the same names are compatible, some error numbers do not match those returned by UNIX implementations. Programs that refer to errors by number rather than by name require a greater conversion effort.
sends on the same socket). AWAITIOX returns a tag and a socket ID so the application can identify which operation just completed. At that point, the application issues a FILE_GETINFO_ call using that file number to get back the completion status of the operation the application just performed (and any other fields such as return length, depending on the operation).
6. 7. Shut down the socket (optional for TCP; not done for UDP or RAW). Close the socket. Designating the NonStop TCP/IP, TCPSAM, or TCP6SAM Process Name To create a socket, the socket-interface library opens a file to communicate with the NonStop TCP/IP, TCPSAM, or TCP6SAM process. Therefore, the socket library must know the name of this process before any sockets are created. Programs can specify this process explicitly by calling the function socket_set_inet_name.
Server Program The 1. 2. 3. 4. 5. 6. 7. 8. basic steps performed by a server program are: Designate the NonStop TCP/IP, TCPSAM, or TCP6SAM process name (optional). Create a socket. Bind the socket to a well-known port (required for most servers; does not apply to RAW; optional for servers started by the LISTNER process). Listen for connections (required for TCP; not done for UDP or RAW). Accept incoming connections.
number of the socket created by your server program and the remote address and port number passed from LISTNER). The programming example on the following pages uses LISTNER to start a server: #include #include #include #include #include #include #include
return 0; } sin.sin_family = AF_INET; /* * Create a socket so that we can use it for * accepting the connection. */ if ((sock = socket (AF_INET, SOCK_STREAM, 0)) < 0) { perror ("socket"); return 0; } /* * This is a waited socket, but we use the trick of * nowait accept_nw2, because this does just what we * need (accept a connection as a new socket).
Table 2 TCP—Nowait Client and Server Steps Client Server 1. Optionally, set NonStop TCP/IP, TCPSAM, or TCP6SAM process name (socket_set_inet_name). 1. Optionally, set NonStop TCP/IP, TCPSAM, or TCP6SAM process name (socket_set_inet_name). 2. Create a socket (socket_nw, followed by AWAITIOX). 2. Create a socket (socket_nw, followed by AWAITIOX). 3. Optionally, bind the socket to any port (bind_nw, followed by AWAITIOX). 3. Bind the socket to a well-known port (bind_nw, followed by AWAITIOX). 4.
See Usage/Bind Considerations (page 87) for information about the HP implementation that handles the binding of UDP sockets. The implementation ensures that the correct process is notified when a broadcast message arrives. Table 4 shows the steps performed by a UDP client and a UDP server in nowait operations. Table 4 UDP—Nowait Client and Server Steps Client Server 1. Optionally, set NonStop TCP/IP, TCPSAM, or TCP6SAM process name (socket_set_inet_name). 2. a. Create a new socket (socket_nw)with 2.
Table 5 RAW—Waited Client and Server Steps Client Server 1. Optionally, set NonStop TCP/IP, TCPSAM, or TCP6SAM process name (socket_set_inet_name). 1. Optionally, set NonStop TCP/IP, TCPSAM, or TCP6SAM process name (socket_set_inet_name). 2. Create a raw socket (socket) assigning 2. a protocol number. The default protocol number is 255. Create a raw socket (socket) specifying the protocol number. 3. Optionally, bind the socket to any local IP address (bind). 3.
Table 6 RAW—Nowait Client and Server Steps (continued) Client Server 6. a. Build the header, as specified by protocol, for type of message being sent. a. Start data transfer (t_recvfrom_nw if connect was not called; recv_nw if connect was called; each followed by AWAITIOX). b. Start data transfer (t_sendto_nw if connect was not called; send_nw if connect was called; each followed by AWAITIOX). b. Read and interpret message header and interpret IP header.
Multicasting Operations Internet Protocol (IP) multicasting provides applications with IP layer access to the multicast capability of Ethernet and networks. IP multicasting, which delivers datagrams on a best-effort basis, avoids the overhead imposed by IP broadcasting on uninterested hosts; it also avoids consumption of network bandwidth by applications that would otherwise transmit separate packets containing identical data to reach several destinations.
a multicast datagram has a TTL value greater than 1 and a multicast router is attached to the sending host's network, multicast datagrams can be forwarded beyond the local subnet. Multicast routers forward the datagram to known networks that have hosts belonging to the specified multicast group. The TTL value is decremented by each multicast router in the path. When the TTL value is decremented to 0, the datagram is not forwarded further.
Before a host can receive IP multicast datagrams destined for a particular multicast group, an application must direct the host to become a member of that multicast group. This section describes how an application can direct a host to add itself to and remove itself from a multicast group.
Flow control can be achieved through: • Rate-based • Sliding window • Explicit pacing • Over subscription (guarantees that the sender cannot overrun the receiver’s capacity. The receiver’s capacity is greatly in excess of the sender’s capacity). A common misconception states that UDP is more efficient than TCP. However, that idea is only true when you do not need flow control, data and session-loss detection, and accounting for receiving out-of-sequence data.
disconnect occurs before the end of file, FTP throws all the data away. FTP is still useful because in fact, loss of connection does not happen often and the cost of retransmission is not always too high. However, a transaction is being transmitted, you must know if it got there and was processed. HP NonStop higher-level protocols frequently used for transaction processing include ODBC and NonStop CORBA which are request/reply model protocols.
2 Porting and Developing IPv6 Applications (NonStop TCP/IPv6 and CIP Only) This section explains how to write Guardian socket applications for IPv4 and IPv6 communications.
3. 4. The application calls socket to create an AF_INET6 socket, using the address family and socket type contained in the addrinfo structure. If the socket call is successful, the application calls connect to establish a connection with host1, using the host address and length in the addrinfo structure. If the connect call is successful, the application sends information to the 3ffe:1200::a00:2bff:fe2d:02b2 address.
1. 2. 3. 4. The application calls getaddrinfo and passes the hostname (host1), the AF_INET6 address family hint, and the AI_ADDRCONFIG and AI_V4MAPPED flag hints. The flag hints tell the function that if an IPv4 address is found for host1, return it as an IPv4-mapped IPv6 address. See addrinfo for a description of hints fields and values. The search finds an IPv4 address, 1.2.3.4, for host1 in the hosts database, and getaddrinfo returns the IPv4-mapped IPv6 address ::ffff:1.2.3.
Figure 4 Using AF_INET6 Socket for IPv4 Communications (Receive) 1. 2. 3. 4. 5. 6. 7. 8. 9. The application calls socket to create an AF_INET6 socket. The application initializes a sockaddr_storage structure, and sets the family, address, and port. The application calls bind to assign in6addr_any to the socket. The application calls accept to mark the socket to listen and wait for incoming connections. An IPv4 packet arrives and passes through the IPv4 module.
addresses. Table 7 lists the currently defined address-testing macros and the return value for a valid test. To use these macros, include the following file in your application: #include The address-testing macros return true if the address is of the specified type, otherwise, they return false.
Table 8 Summary of IPv6 Extensions to the BSD Socket API (continued) Category Changes and inet_addr functions remain for IPv4 address conversion only. See Making Library Routine Changes (page 56) for more information. Socket options Specifies new socket options for IPv6 multicast. See Multicast Changes for IPv6 (page 59) for more information. Application Changes This subsection describes the changes you must make in your existing application code in order to operate in an IPv6 networking environment.
Make the following changes in your application, as needed: Original Change to Structure Name in_addr in6_addr Data Type unsigned long u_char Field Name s_addr sa6_addr See Making Other Application Changes (page 57) for additional changes you might need to make to your application. See also in6_addr (page 70) for alternative definitions of the in6_addr data structure. sockaddr_in Structure Changes for IPv6 Applications Applications that use the 4.
NOTE: In both cases, you should initialize the entire sockaddr_in6 structure to zero after your structure declarations.
1. 2. 3. Change the function name from gethostbyname to getaddrinfo. Provide: • a character string for the returned node name • a character string for the service name • a pointer to a hints structure that contains processing options • a pointer to an addrinfo structure or structures for the returned address information. (See getaddrinfo (page 107) for a description of hints fields and values.
Comparing IP Addresses If your application compares IP addresses or tests IP addresses for equality, the in6_addr structure changes you made in Making Structure Changes (page 54) change the comparison of int quantities to a comparison of structures. This modification breaks the code and causes compiler errors.
Using Functions That Return IP Addresses If your application uses functions that return IP addresses as int data types, the in6_addr structure changes you made in Making Structure Changes (page 54) changes the destination of the return value from an int to an array of char. This modification breaks the code and causes compiler errors.
The hop limit value is decremented by each multicast router in the path. When the hop limit value is decremented to 0, the datagram is not forwarded further.
. imr6.ipv6mr_interface = if_index; if (setsockopt( sock, IPPROTO_IPV6, IPV6_JOIN_GROUP, (char *)&imr6, sizeof(imr6)) < 0) perror("setsockopt: IPV6_JOIN_GROUP error"); The / variable has the following structure: struct ipv6_mreq { struct in6_addr ipv6mr_multiaddr; /*IP multicast address of group*/ unsigned int ipv6mr_interface; /*local interface index*/ }; Each multicast group membership is associated with a particular interface. It is possible to join the same group on multiple interfaces.
3 Data Structures This section describes the library header files and the data structures declared in the headers. The function declarations and data structures contained in the header files are used by the socket library routines described in Chapter 4. Library Headers The declarations of the functions in the socket library are provided in both C and TAL programming languages. Other languages can be used to interface to the socket library, subject to C compiler restrictions.
Some of the following C header files are used internally by the NonStop TCP/IP, Parallel Library TCP/IP, and NonStop TCP/IPv6 subsystems; others are useful in some application programs. The files are user-readable and contain comments describing their contents, as follows: af.h insystm.h nameser.h sockvar.h tcpseq.h udpvar.h domain.h invar.h netisr.h syscal.h tcptimr.h uio.h icmpvar.h ip.h param.h tcp.h tcpvar.h user.h ifarp.h ipicmp.h protosw.h tcpdeb.h time.h ifether.h ipvar.
The data structures used by the support routines are built from the following data files: • $SYSTEM.ZTCPIP.HOSTS • $SYSTEM.ZTCPIP.IPNODES (NonStop TCP/IPv6 only) • $SYSTEM.ZTCPIP.SERVICES • $SYSTEM.ZTCPIP.NETWORKS • $SYSTEM.ZTCPIP.PROTOCOL The formats of these four data files are given in the TCP/IPv6 Configuration and Management Manual.
not set, the returned address can be passed to the connect function. If hostname is NULL, the address is set to the loopback address. AI_CANONNAME Requests the return of the canonical name for the host if the hostname is not NULL. AI_NUMERICHOST Specifies that the hostname value is a numeric address string. If this flag is set and hostname is not a numeric address string, the returned value is set to EAI_NONAME. Use this flag to prevent calling a name resolution service like DNS.
struct sockaddr arp_pa; struct { unsigned short unsigned char }arp_ha; short arp_flags; sa_family; sa_data[6]; }; TAL Declaration ?NOLIST, SOURCE SOCKDEFT STRUCT arpha (*); BEGIN INT sa_family; STRING sa_data[0:5]; END; STRUCT arpreq; BEGIN STRUCT STRUCT INT END; arp_pa (sockaddr); arp_ha (arpha); arp_flags; arp_pa contains the Internet address of the machine. NOTE: Since arp_pa is a sockaddr struct, it contains fields for the port, address family, and Internet address.
TAL Declaration ?NOLIST, SOURCE SOCKDEFT STRUCT haliase (*); BEGIN STRING .EXT ptrs; END; STRUCT hptrs (haliase)[0:4]; STRUCT ha_aliase (*); BEGIN STRING .EXT ptrs; END; STRUCT ha_ptrs (ha_aliase)[0:4]; STRUCT hostent (*); BEGIN STRING STRING INT(32) INT(32) STRING END; .EXT h_name; .EXT h_aliases (hptrs); h_addrtype; h_length; .EXT h_addr_list (ha_ptrs); h_name points to the official name of the host. h_aliases points to an array of pointers to the various aliases assigned to the host.
STRUCT if_nameindex_tal (*); BEGIN INT(32) STRING .EXT END; if_index; if_name; if_index specifies the index to be mapped to an interface name. if_name specifies the buffer to receive the mapped name. The buffer must be at least IF_NAMESIZE bytes long; IF_NAMESIZE is defined in the header file in.h. ifreq The interface request structure is used for socket I/O control operations. All interface control operations must have parameter definitions that begin with ifr_name.
ifr_name[IFNAMESIZ] contains the name of the SUBNET device. The name must begin with the pound sign (#), followed by the interface name in all capital letters. ifr_addr is the interface address. ifr_dstaddr is the destination address at the other end of a point-to-point link. ifr_broadaddr is the broadcast address of this interface. ifr_flags contains a combination of one or more of the following flags: IFF_UP Indicates that the interface is up.
in6_addr This structure holds a single IPv6 address. This structure is implemented with an embedded union with extra fields that force an alignment level in a manner similar to BSD implementations of struct in_addr. This structure is used by the socket routines and is declared in the in6.h header file. This structure applies to NonStop TCP/IP only. C Declaration #include struct in6_addr union { u_char sa6_addr[16]; #define s6_addr s6_un.sa6_addr u_short sa6_waddr[8]; #define s6_waddr s6_un.
?NOLIST, SOURCE SOCKDEFT STRUCT ip_mreq (*); BEGIN STRUCT imr_multiaddr (in_addr); !IP multicast group address !local interface STRUCT imr_interface (in_addr); !IP address END; imr_multiaddr contains the address of the IP multicast group to join membership to or drop membership from. imr_interface is the interface IP address. ipv6_mreq The IP multicast request structure is used for IPv6 multicast socket I/O control operations. This structure is used by the socket routines and is declared in the in6.
unsigned long }; TAL Declaration n_net; ?NOLIST, SOURCE SOCKDEFT STRUCT naliase (*); BEGIN STRING END; .EXT ptrs; STRUCT nptrs (naliase)[0:4]; STRUCT netent (*); BEGIN STRING .EXT STRING .EXT INT(32) INT(32) END; n_name; n_aliases(nptrs); n_addrtype; n_net n_name points to the official name of the network. n_aliases points to an array of null-terminated pointers to various aliases for the network.
INT INT INT INT INT INT INT filename_len; flags; sync; access; exclusion; nowait; options; END; filenum specifies the file number of the opened file. file_name is the name of the file. filename_len is the length, in bytes, of the contents of file_name. flags specifies flag values that affect the file. sync specifies the sync-depth value of the file. access is the access mode of the file. exclusion is the mode of compatibility with other openers of the file.
STRING STRING INT(32) .EXT p_name; .EXT p_aliases(pptrs); p_proto; END; p_name points to the official name of the protocol. p_aliases points to an array of null-terminated pointers to various aliases for the protocol. p_proto is the protocol number. rtentry The route entry structure is used when adding or deleting routes. It is defined in the route.h header file. NonStop TCP/IPv6 and NonStop TCP/IPv6 distinguish between routes to hosts and routes to networks.
rt_dst is the destination of the route. rt_gateway is the gateway to the destination. rt_flags contains a combination of one or more of the following flags: RTF_UP Indicates the route is up and can be used. RTF_GATEWAY Indicates the destination is a gateway. RTF_HOST Indicates the route is a host entry in a point-to-point table. (Otherwise, the route is an entry in a network table.) RTF_MDOWN Indicates the route has been temporarily marked down.
sendto_recvfrom_buf This structure is used by the recvfrom_nw and sendto_nw routines. It is defined in the in.h header file. C Declaration #include struct sendto_recvfrom_buf { struct sockaddr_in sb_sin; char sb_data[1]; }; #define sb_sent sb_sin.sin_family #define SOCKADDR_IN TAL Declaration ?NOLIST, SOURCE SOCKDEFT STRUCT sendto_recvfrom_buf (*); BEGIN STRUCT STRING sb_sin(sockaddr_in); sb_data[0:1]; END; sb_sin is an address-port number combination based on the structure sockaddr_in.
STRING INT(32) STRING .EXT s_aliases(sptrs); s_port; .EXT s_proto; END; s_name points to the official name of the service. s_aliases points to an array of null-terminated strings to the various aliases for the service. s_port is the port number associated with the service, in network order. s_proto points to the name of the protocol associated with the service. sockaddr This structure, defined in the in.h header file, is a pointer to the sockaddr_in structure. C Declaration #include
The #include directive contains the declaration of the sockaddr_in structure. The program declares that the sin structure is based on the sockaddr_in structure. The socket s1 is created by a call to the socket routine. The bind routine syntax requires that the address and port number that you want to bind to the socket be stored in a structure based on the sockaddr_in structure. The routine also requires that you pass a pointer to that structure (sin, in this example).
struct sockaddr_in6 { u_short sin6_family; /* AF_INET6 */ u_short sin6_port; /* Transport layer port # */ u_long sin6_flowinfo; / *IPv6 flow info */ struct in6_addr sin6_addr; /* IPv6 address */ u_long sin6_scope_id; / *set of interfaces for scope */ }; TAL Declaration ?NOLIST, SOURCE SOCKDEFT STRUCT sockaddr_in6 (*); BEGIN INT sin6_family; INT sin6_port; INT(32) sin6_flowinfo; STRUCT sin6_addr(in6_addr); INT(32) sin6_scope_id; END; sin6_family is the type of address. Its value is always AF_INET6.
__ss_pad1 is a 6-byte pad up to the _ss_align field. __ss_align forces the alignment of the field. __ss_pad2 is the 112-byte pad to the desired size of the field.
4 Library Routines This section contains the syntax and semantics for the socket-library routines provided by the NonStop TCP/IP, NonStop TCP/IP, and NonStop TCP/IP products. These routines are compatible with the socket routines in the 4.3 BSD UNIX operating system, except as noted here or in the Porting Considerations (page 32).
Support routines assist in name translation, enabling you to use easy-to-understand symbolic names for objects, hosts, and services. However, they are not essential for data transmission using the socket library, and only two of them—gethostname and gethostid—communicate with the TCP/IP process. NOTE: Certain socket options are supported differently in CIP. See the Cluster I/O Protocols (CIP) Configuration and Management Manual for details.
Table 12 Socket Routines (continued) Name and Description Page Function sendto_nw (page 180) Sends data on an unconnected UDP or raw socket without byte-count header (nowait) sendto_nw64_ (page 182) Sends data on an unconnected UDP or raw socket without byte-count header (nowait) in 64–bit application.
Table 13 Support Routines (continued) 84 Routine Name Functions getipnodebyaddr (page 114) Gets the name of the host that has a specified Internet address and provides an error-number value to maintain a thread-safe environment. (Supported by NonStop TCP/IP only.) getipnodebyname (page 116) Provides lookups for IPv4/IPv6 hosts. (Supported by NonStop TCP/IPv6 only.) getnameinfo (page 117) Translates a protocol-independent host address to a hostname and gives the service name.
Table 13 Support Routines (continued) Routine Name Functions lwres_getaddrinfo (page 142) Converts hostnames and service names into socket address structures. (Supported for NonStop TCP/IPv6 only.) lwres_gethostbyaddr (page 144) Gets the name of the host that has the specified Internet address and address family. (Supported for Parallel Library TCP/IP only.) lwres_gethostbyname (page 145) Gets the Internet address (IPv4) of the host whose name is specified. (Supported for NonStop TCP/IPv6 only.
the text message associated with the current error to the standard C error file (the file named stderr). The text message description of each routine lists most error numbers that can be returned in errno on a call to the particular routine. A complete list of socket errors and their meanings is given in Appendix B (page 243). You must interpret the meaning of each error according to the type of call and the circumstances in which your program issues the call.
Procedure Prototypes Each socket function described in this manual is available to be “sourced” into TAL programs. Either the entire set of prototypes or individual functions may be sourced. Because TAL procedures cannot be type cast for returning pointers, those procedures that actually do return pointers are typed as INT(32). It is the programmer’s responsibility to redefine the returned INT(32) as a pointer to the appropriate structure.
3. 4. Source SOCKDEFT to reference socket library structures. Specify the CRE compiler directive (ENV COMMON) either in the program source code or in the compilation line. pTAL does not have access to the CRE initialization routine. For information about running a pTAL program in the CRE environment, see the TNS/R Native Application Migration Guide. 1. All addresses must be 32 bits (.EXT). 2. Source SOCKPROC to reference socket library procedures. 3. Source SOCKDEFT to reference socket library structures.
NOTE: HP recommends that you use the Common Run-Time Environment (CRE) when developing TAL socket applications. CRE is described in the CRE Programming Manual. If your application is incompatible with CRE, use the CRE-Independent socket library described in “Socket Libraries” at the beginning of this section. Native Mode C/C++ Issues Users of the native mode C/C++ compiler (nmc) need to specify the extensions compiler pragma for correct compilation of the socket library header files.
Errors If an error occurs, the external variable errno is set to one of the following values: ECONNRESET The connection was reset by the peer process before the accept operation completed. EINVAL An invalid argument was specified. Usage Guidelines • This is a waited call; your program is blocked until the operation completes. For nowait I/O, use accept_nw and accept_nw2. • For TCP server applications, a call to bind and listen must precede a call to accept.
/* Notice from is cast to struct sockaddr in the following call as suggested in the Usage Guidelines */ if ((s2 = accept(fd, (struct sockaddr *)&from, &flen)) < 0) { perror ("Server: Accept failed."); exit (0); } inet_ntop(AF_INET6, &from.sin6_addr, buf, sizeof(buf)); printf ("Server Connected from remote %s.%d\n", buf, from.sin6_port); accept_nw The accept_nw function checks for connections on an existing nowait socket.
tag input value; the tag parameter to be used for the nowait operation. Errors If an error occurs, the external variable errno is set to one of the following values: EALREADY There is already an outstanding call on the socket. ECONNRESET The connection was reset by the peer process before the accept_nw operation completed. EINVAL An invalid argument was specified.
flen = sizeof(from); if ((cc = accept_nw(fd1, (struct sockaddr *)&from, flen, t)) < 0) { perror ("Server: Accept failed."); exit (0); } else { /* Call AWAITIOX using socket fd1 and tag t. */ ... } if ((fd2 = socket_nw(AF_INET, SOCK_STREAM,,1,1)) < 0) { perror ("Server Socket 2 create failed."); exit (0); } else { /* Call AWAITIOX using socket fd2. */ }... if ((cc = accept_nw2(fd2, (struct sockaddr *)&from, t)) < 0) { perror ("Server: Accept failed.
perror ("Server Socket 2 create failed."); exit (0); } else { /* Call AWAITIOX using socket fd2. */ }... if ((cc = accept_nw2(fd2, (struct sockaddr *)&from, t)) < 0) { perror ("Server: Accept failed."); exit (0); } else { /* Call AWAITIOX using socket fd2 and tag t. */ ... } accept_nw1 accept_nw1 can be used instead of accept_nw; use accept_nw1 to set the maximum connections in the queue awaiting acceptance on a socket. C Synopsis #include #include #include
from_len1 input and return value; points to a value indicating the size in bytes of the structure pointed to by from_ptr. tag input value; the tag parameter to be used for the nowait operation. queue_length input value; specifies the maximum queue length (number of pending connections). Values are 1 through 128. Errors If an error occurs, the external variable errno is set to one of the following values: EALREADY There is already an outstanding call on the socket.
struct sockaddr *from_ptr; long tag; TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC error := accept_nw2 (new_socket, from_ptr, tag); INT(32) error; INT(32) new_socket; INT .EXT from_ptr(sockaddr_in); INT(32) tag; error return value; f the call is successful, a zero is returned. If the call is not successful, –1 is returned. If the call failed, the external variable errno is set as indicated in Errors (page 96).
address-port number combination returned by accept_nw is passed to accept_nw2 to establish the connection on the new socket. • The call to accept_nw made prior to this call may be made in another process, such as the LISTNER process. • Declare the from_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.
tag input value; the tag parameter to be used for the nowait operation. Errors If an error occurs, the external variable errno is set to one of the following values: EADDRINUSE Accept_nw3() posted on an already-bound socket. (For Parallel Library TCP/IP and NonStop TCP/IPv6 only.) EALREADY Operation is already in progress. (For Parallel Library TCP/IP and NonStop TCP/IPv6 only.) ECONNRESET The connection was reset by the peer process before the accept operation completed.
int error, socket; struct sockaddr *address_ptr; int address_len; long tag; TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC error := bind (socket, address_ptr, address_len); error := bind_nw (socket, address_ptr, address_len, tag); INT(32) error, socket; INT .EXT address_ptr(sockaddr_in); INT(32) address_len; INT(32) tag; error return value; if the call is successful, a zero is returned. If the call is not successful, —1 is returned.
EINVAL The specified socket was already bound to an address, or the address_len was incorrect. EACCES The specified address cannot be assigned to a nonprivileged user. Usage Guidelines • Use bind on a socket created for waited operations, or bind_nw on a socket created for nowait operations. The operation initiated by bind_nw must be completed with a call to the AWAITIOX procedure. NOTE: The socket goes into a TCP LISTEN state after the application completes a bind on an IP address and port.
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.
#include ... struct sockaddr_in6 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.sin6_family = AF_INET6; sin.sin6_addr = in6addr_any; sin.sin6_port = port; /* Notice that sin is cast as sockaddr as suggested in the Usage Guidelines */ if (bind (fd, (struct sockaddr *)&sin, sizeof (sin)) < 0) { perror ("SERVER: Bind failed.
socket input value; specifies the socket number for the socket, as returned by the call to socket or socket_nw. address_ptr input value; points to the address and port number (based on the structure sockaddr_in, sockaddr_in6, sockaddr_storage) of the remote socket to which a connection is to be established. address_len input value; should be a value indicating the size in bytes of the remote address and port number pointed to by address_ptr.
/* Program must contain code to create the socket fd * and to fill in the remote address before calling connect. */ ... if (connect (fd,(struct sockaddr *)&remote,sizeof(remote)) <0) { perror ("Client failed to connect to remote host."); exit (0); } printf ("CLIENT:Connected ...\n"); INET6: The following programming example calls the connect routine that connects the socket fd to a remote socket. The remote structure contains the address and port of the remote socket: #include #include
Usage Guidelines Call this function once for each structure created by calls to getaddrinfo before closing a socket. Upon successful completion, freeaddrinfo does not return a value. The address information structure and associated storage are returned to the system. Examples INET6: the following IPv6 programming example calls the freeaddrinfo routine after the getaddrinfo function returns a value: #include ...
The gai_strerror function call returns a pointer to a character string describing the error code passed into it. (This function is supported for Parallel Library TCP/IP only.) C Synopsis #include char *gai_strerror (int ecode); TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC return_value := gai_strerror (ecode); INT(32) return_value; INT(32) ecode; return_value is a pointer to a string described in ecode.
Example The following programming example calls the gai_strerror routine to print error messages: error = getaddrinfo(hostname, servicename, &hints, &res); if(error != 0) { (void)fprintf(stderr,"myFunction: getaddrinfo returned error %i ", error); (void)fprintf(stderr,"%s0", gai_strerror(error)); return -1; } Errors errno is set only on the return of EAI_SYSTEM. See ecode for further information about error codes.
service input value; specifies a pointer to a character representing one of the following: • A network service name. • A decimal port number. • NULL if no service name requires converting; when NULL is used, either hostname or hints must be non-NULL. hints input value; specifies one of the following: • A pointer to an addrinfo struct for a socket; the format of the addrinfo structure is defined in the header file netdb.h.
functionality beyond what getipnodebyname provides because getaddrinfo handles both the hostname and the service. • Appropriate use of this function can eliminate calls to getservbyname and at the same time provide protocol independence. • getaddrinfo function converts hostnames and service names into socket address structures. You allocate a hints structure, initialize it to 0 (zero), fill in the needed fields, and then call this function.
?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC host_entry_ptr := gethostbyaddr (host_addr_ptr, length, addr_type); host_entry_ptr := host_file_gethostbyaddr (host_addr_ptr, length, addr_type); INT(32) host_entry_ptr; STRING .EXT host_addr_ptr; INT(32) length, addr_type; host_entry_ptr return value; points to a structure (based on the hostent structure) in which information on the specified host is returned. The information includes the official name, aliases, and addresses for the host.
host_entry_ptr = gethostbyname (host_name_ptr); host_entry_ptr = host_file_gethostbyname (host_name_ptr); struct hostent *host_entry_ptr; char *host_name_ptr; TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC host_entry_ptr := gethostbyname (host_name_ptr); host_entry_ptr := host_file_gethostbyname (host_name_ptr); INT(32) host_entry_ptr; STRING .
struct sockaddr_in sin; struct hostent *hp; ... if ((hp = gethostbyname (nameptr)) != (struct hostent *) NULL) { memmove ((char *)&sin.sin_addr.s_addr, (char *)hp -> h_addr, (size_t) hp -> h_length ); } ... If the return value is not NULL, the pointer hp is used to move the address from the h_addr field of the hp structure to the Internet address field of the sin structure. gethostbyname2 The gethostbyname2 function gets the Internet address (IPv4 or IPv6) of the host whose name is specified.
NO_RECOVERY An error has occurred from which there is no recovery. Example The example makes a call to gethostbyname2 by passing the host-name and address family as arguments. If an answer is found, a pointer to the hostent structure is returned and stored in hp. NULL is returned if no answer is found. int af; char *name; struct hostent *hp; hp = gethostbyname2(name, af); Usage Guidelines • The parameter name passed to the gethostbyname2 function is case-sensitive.
char buffer []; socklen_t buffer_length; TAL Synopsis ?NOLIST, SOURCE SOCKPROC ?NOLIST, SOURCE SOCKDEFT error := gethostname (buffer, buffer_length); INT(32) error; STRING .EXT buffer; INT(32) buffer_length; error return value; if the call is successful, a zero is returned. If the call is not successful, —1 is returned. If the call failed, the external variable errno is set as indicated in Errors (page 114). buffer return value; a character array in which the official name of the local host is returned.
INT .EXT error_ptr; return_value is a pointer to a structure of type hostent. src input value; a pointer to an IP address for which the hostname should be returned; the address specified should be in binary format and network order. len input value; the length of the IP address: 4 octets for AF_INET or 16 octets for AF_INET6. af input value; member of address family AF_INET or AF_INET6. error_ptr input and return value; a pointer to the integer containing an error code, if any.
getipnodebyname The getipnodebyname function gets host information based on the hostname. This function is protocol-independent. (This function is supported for Parallel Library TCP/IP only.) NOTE: The C synopsis is given in ANSI C format rather than the pre-ANSI C formats of the other library routines because the only NonStop servers you can use these routines on all support ANSI C.
struct sockaddr_in sin; struct hostent *hp; ... if ((hp = getipnodebyname (nameptr, AF_INET, AI_PASSIVE, &error_num)) != (struct hostent *) NULL) { memmove ((char *)&sin.sin_addr.s_addr, (char *)hp -> h_addr, (size_t) hp -> h_length ); } ... Usage Guidelines • The getipnodebyname function searches host entries sequentially until a match with the name argument occurs.
INT .EXT INT(32) STRING .EXT INT(32) STRING .EXT INT(32) INT(32) sa(sockaddr); salen; host; hostlen; serv; servlen; flags; error return value; if the call is successful, a 0 (zero) is returned. If the call is not successful, —1 is returned. If the call failed, the external variable error is set as indicated in Errors (page 119). sa input value; points to the sockaddr_in or sockaddr_in6 struct containing the IP address and port number. salen input value; specifies the length of the sa argument.
Usage Guidelines • By default, this function returns the hostname’s fully qualified domain name. • This function, along with getipnodebyaddr, are protocol-independent replacements for gethostbyaddr, host_file_gethostbyaddr. getnameinfo provides extra functionality beyond what getipnodebyaddr provides because it handles both the host’s address and port number. • Appropriate use of this function can eliminate calls to getservbyport and at the same time provide protocol independence.
INT(32) net_addr; net_entry_ptr return value; points to a structure (based on the netent structure) that contains all the required information on the specified network. This is the return value. If the lookup fails (for instance, if the specified network address is invalid, if no NETWORKS file exists, if the NETWORKS file could not be opened, or if no matching network entry is found in the NETWORKS file), NULL is returned. net_addr input value; the network address by which the network is to be found.
Errors No errors are returned for this function. Usage Guidelines • This call requires the presence of a NETWORKS file providing information on the networks accessible from this host. The format of this file is described in the TCP/IPv6 Configuration and Management Manual. • The parameters passed to the getnetbyname function are case-sensitive. • The netent structure is statically declared. Subsequent calls to getnetbyname replace the existing data in the netent structure.
address_len_ptr input and return value; maintained only for compatibility and should point to a value indicating the size in bytes of the structure (the remote address and port number) pointed to by address_ptr. tag input value; the tag parameter to be used for the nowait operation initiated by getpeername_nw. Errors If an error occurs, the external variable errno is set to one of the following values: ENOTCONN The specified socket was not connected. EINVAL One of the specified arguments was invalid.
proto_name_ptr input value; points to a null-terminated character string that contains the protocol name. Errors No errors are returned for this function. Usage Guidelines • This call requires the presence of a PROTOCOL file providing information on the available protocols. The information in the default PROTOCOL file is given in Appendix A (page 241). The format of this file is described in the TCP/IPv6 Configuration and Management Manual.
proto input value; the Internet protocol number of the protocol. Errors No errors are returned for this function. Usage Guidelines • This call requires the presence of a PROTOCOL file providing information on the available protocols. The information in the default PROTOCOL file is given in Appendix A (page 241). The format of this file is described in the TCP/IPv6 Configuration and Management Manual. • The protoent structure is statically declared.
proto_ptr input value; points to a null-terminated character string that contains the name of the protocol associated with the service. Errors No errors are returned for this function. Usage Guidelines • This call requires the presence of a SERVICES file providing information on the available services. The information in the default SERVICES file is given in Table 19 (page 242).
Usage Guidelines • This call requires the presence of a SERVICES file providing information on the available services. The format of this file is described in the TCP/IPv6 Configuration and Management Manual and in the Cluster I/O Protocols Configuration and Management Manual. • The servent structure is statically declared. Subsequent calls to getservbyport replaces the existing data in the servent structure.
address_len_ptr input and return value; maintained only for compatibility and should be a value indicating the size in bytes of the structure (the remote address and port number) pointed to by address_ptr. tag input value; the tag parameter to be used for the nowait operation initiated by getsockname_nw. Errors If an error occurs, the external variable errno is set to the following value: An invalid argument was specified.
getsockopt, getsockopt_nw The getsockopt and getsockopt_nw functions return the socket options for a socket. C Synopsis #include #include #include #include /* for IPv6 use */
user-protocol can be any protocol number other than the numbers for TCP, UDP, IP, ICMP, and raw. Appendix A (page 241), lists the protocol numbers. optname input value; the socket option name. When level is SOL_SOCKET, the possible values are: SO_BROADCAST Get the value of the SO_BROADCAST flag. See setsockopt, setsockopt_nw (page 184) for details. SO_ERROR Get the error status and clear the socket error. This option applies only to the getsockopt function. SO_TYPE Get the socket type.
TCP_MAXRXMT Get the value of the TCP_MAXRXMT flag. See setsockopt, setsockopt_nw (page 184) for details. TCP_RXMTCNT Get the value of the TCP_RXMTCNT flag. See setsockopt, setsockopt_nw (page 184) for details. TCP_TOTRXMTVAL Get the value of the TCP_TOTRXMTVA flag. See setsockopt, setsockopt_nw (page 184) for details. When level is a user-defined protocol above IP, the possible values are defined by the protocol.
#include void if_freenameindex (struct if_nameindex *ptr); TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC if_freenameindex(ptr); INT .EXT ptr; ptr input value; specifies the address pointer returned by the if_nameindex function for which storage should be returned to the system. Errors This function does not return a value. Upon successful completion, all dynamic storage associated with the interface index has been returned to the system.
TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC name^ptr = if_indextoname(ifindex, char *ifname); INT(32) name^ptr; INT(32) ifindex; STRING .EXT ifname; name^ptr return value; a pointer to the interface name string. If there is no interface corresponding to the specified index, NULL is returned, and error is as described in Errors (page 132). ifindex input value; specifies the index to be mapped to an interface name. ifname input value; specifies the buffer to receive the mapped name.
#include #include #include #include struct if_nameindex *if_nameindex(void); TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC return_value = if_nameindex(); INT(32) return_value; Errors Upon successful completion, this function returns a pointer to an array of if_nameindex structures. The end of the array is a structure that has an if_index value of 0 (zero) and an if_name value that is NULL pointer. Otherwise, this function returns NULL.
index = if_nametoindex(ifname); INT(32) index; STRING .EXT ifname; index return value; upon successful completion, if_nametoindex returns the interface index corresponding to the interface name specified in ifname. Otherwise, this function returns 0 (zero). ifname input value; points to a buffer that holds the name of the interface (subnet) to be mapped to an index number. The name specified cannot be larger than IFNAMSIZ, as defined in the if.h header file.
Errors 0xffffffffl is returned if the character string that is passed is not an Internet address. Example See UDP Client Program (page 219) for an example that calls inet_addr. inet_lnaof The inet_lnaof function breaks apart an INET Internet address and returns the local address portion. C Synopsis #include #include /* for IPv6 use */ #include
INT(32) inaddr, net, lna; inaddr return value; the corresponding 4-byte Internet address. This is the return value. net input value; the network address portion of the Internet address. lna input value; the local address portion of the Internet address. Errors No errors are returned for this function. inet_netof The inet_netof function breaks apart an INET family Internet address and returns the network address portion. C Synopsis #include #include /* for IPv6 use */ #include
unsigned long l_addr; char *addr_ptr; TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC l_addr := inet_network (addr_ptr); INT(32) l_addr ; STRING .EXT addr_ptr; l_addr return value; the network address portion of the Internet address. This is the return value. addr_ptr input value; points to an Internet address in dotted-decimal format. Errors No errors are returned for this function. inet_ntoa The inet_ntoa function converts an address from binary format to dotted-decimal format.
inet_ntop The inet_ntop function converts an IPv6 or IPv4 binary address to a character string. (This function is supported for Parallel Library TCP/IP only.) NOTE: The C synopsis is given in the ANSI C format rather than the pre-ANSI C formats of the other library routines because the only NonStop servers you can use these routines on all support ANSI C. (The ANSI C format defines the function and the arguments in the same line rather than using an assign statement and defining the arguments underneath.
Errors Upon successful completion, this function returns a pointer to the dst buffer. Otherwise, this function returns NULL and errno is set to indicate the error. If any of these conditions occurs, the function sets errno to the corresponding value: EAFNOSUPPORT The value specified for the af parameter is not valid. ENOSPC The value specified for the size parameter is not valid for the address family.
1080::8:800:200C:417A • In mixed form as x:x:x:x:x:x:d.d.d.d, for example: ::FFFF:13.1.68.3 as a mapped value, or ::13.1;68.3 as a compatible value. dst input and return value; receives the converted address in network byte order. NOTE: The maximum length of an IPv4 address as a text string is defined as INET_ADDRSTRLEN in the in.h header file. The maximum length of an IPv6 address as a text string is defined as INET6_ADDRSTRLEN in the in6.h header file.
lwres_freehostent The lwres_freehostent function frees the memory of one or more hostent structures returned by the lwres_getipnodebyaddr or lwres_getipnodebyname functions. (This function is supported for G06.27 and later G-series RVUs and H06.05 and later H-series RVUs of NonStop TCP/IPv6.) C Synopsis #include void lwres_freehostent(struct hostent *ptr); TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC lwres_freehostent( ptr); INT .
EAI_AGAIN temporary failure in name resolution. EAI_BADFLAGS invalid value for ai_flags. EAI_FAIL non-recoverable failure in name resolution. EAI_FAMILY ai_family not supported. EAI_MEMORY memory allocation failure. EAI_NODATA no address associated with hostname. EAI_NONAME hostname or servname not provided, or not known. EAI_SERVICE servname not supported for ai_socktype. EAI_SOCKTYPE ai_socktype not supported. EAI_SYSTEM system error returned in errno.
int lwres_getaddrinfo (const char *hostname, const char *servname, const struct addrinfo *hints, struct addrinfo **result); TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC error := lwres_getaddrinfo (hostname, servname, hints, result); INT error; STRING .EXT hostname; STRING .EXT servname; INT .EXT hints(addrinfo); INT .EXT result(addrinfo); hostname input value; specifies a pointer to a character representing one of the following: • An Internet node hostname.
hints.ai_socktype = SOCK_STREAM; ret = getaddrinfo(hostname, servname, &hints, &res); if (ret != 0) { fprintf(stderr, "%s not found in name service database\n", hostname); exit(1); } for (ainfo = res; ainfo != NULL; ainfo = ainfo->ai_next) { /* Create the socket.
host_entry_ptr return value; points to a structure (based on the hostent structure) in which information about the specified host is returned. The information includes the official name, aliases, and addresses for the host. If the lookup fails, NULL is returned, and the external variable lwres_h_errno is set as indicated below under Errors. addr input value; points to the Internet address of the host whose name is to be found. The address pointed to is in binary format and network order.
?NOLIST,SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC host_entry_ptr := lwres_gethostbyname(name); INT(32) host_entry_ptr; STRING .EXT name; host_entry_ptr return value; points to a structure (based on the hostent structure) in which information about the specified host is returned. The information includes the official name, aliases, and addresses for the host. If the lookup fails, NULL is returned, and the external variable lwres_h_errno is set as indicated below under Errors.
TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC host_entry_ptr := lwres_gethostbyname2(name, af); INT(32) host_entry_ptr; STRING .EXT name; INT af; host_entry_ptr return value; points to a structure (based on the hostent structure) in which information about the specified host is returned. The information includes the official name, aliases, and addresses for the host. If the lookup fails, NULL is returned, and the external variable lwres_h_errno is set as indicated below under Errors.
specify data from a Name Server. (This function is supported for G06.27 and later G-series RVUs and H06.05 and later H-series RVUs of NonStop TCP/IPv6.) C Synopsis #include #include return_val = lwres_getipnodebyaddr(const void *src, socklen_t len, int af, int *error_ptr); TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC return_val := lwres_getipnodebyaddr( src, len, af, error_ptr); INT(32) return_val; STRING .EXT src; INT(32) len; INT af; INT .
A successful function call returns a pointer to the hostent structure that contains the hostname. The structure returned also contains the values used for src and address-family. lwres_getipnodebyname The lwres_getipnodebyname function gets host information based on the hostname. This function is protocol-independent. (This function is supported for G06.27 and later G-series RVUs and H06.05 and later H-series RVUs of NonStop TCP/IPv6.) C Synopsis #include
Errors If an error occurs, lwres_getipnodebyname and lwres_getipnodebyaddr set *error_ptr to an appropriate error code, and the function returns a NULL pointer. The error codes and their meanings are defined in netdb.h: HOST_NOT_FOUND The host or address was not found. TRY_AGAIN A recoverable error occurred, for example, a timeout. Retrying the lookup may succeed. NO_RECOVERY A non-recoverable error occurred.
INT error; INT .EXT sa(sockaddr); INT(32) salen; STRING .EXT host; INT(32) hostlen; STRING .EXT serv; INT(32) servlen; INT flags; error return value; if the call is successful, a 0 (zero) is returned. If the call is not successful, —1 is returned. sa input value; points to the sockaddr_in or sockaddr_in6 struct containing the IP address and port number. salen input value; specifies the length of the sa argument.
Errors Upon successful completion, this function returns 0 (zero) and the requested values are stored in the buffers specified for the call. Otherwise, the value returned is nonzero and errno is set to indicate the error (only when the error is EAI_SYSTEM). See the return values described for lwres_gai_strerror (page 141). Example The example calls the lwres_getnameinfo routine to get a hostname's fully qualified domain name.
NO_RECOVERY Unknown server error. NO_DATA No address associated with hostname. listen The listen function is provided for compatibility only. In other socket implementations, listen sets the maximum connections that are in the queue awaiting acceptance on a socket. In the NonStop TCP/IP, Parallel Library TCP/IP, and NonStop TCP/IPv6 implementations, the maximum pending connections is always 5. A call to listen must precede a call to accept or accept_nw.
error = recv_nw (socket, buffer_ptr, length, flags, tag); int nrcvd, socket; char *buffer_ptr; int length, flags, error; long tag; TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC nrcvd := recv (socket, buffer_ptr, length, flags); error := recv_nw (socket, buffer_ptr, length, flags, tag); INT(32) nrcvd, socket; STRING .EXT buffer_ptr; INT(32) length, flags, error; INT(32) tag; nrcvd return value; the number of bytes received by the recv function. This is the return value for recv.
Errors If an error occurs, the return value is set to -1 and the external variable errno is set to one of the following values: EHAVEOOB There is out-of-band data pending. This must be cleared with a call to recv with the MSG_OOB flag set. (This error does not apply to UDP sockets.) ENOTCONN The specified socket was not connected. ESHUTDOWN The specified socket was shut down. ETIMEDOUT The connection timed out. ECONNRESET The connection was reset by the remote host.
C Synopsis #include #include nrcvd = recv64_ (socket, buffer_ptr64, length, flags); error = recv_nw64_ (socket, buffer_ptr64, length, flags, tag); int nrcvd, socket; char _ptr64 *buffer_ptr64; int length, flags, error; long long tag; TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC nrcvd := recv64_ (socket, buffer_ptr64, length, flags); error := recv_nw64_ (socket, buffer_ptr64, length, flags, tag); INT(32) nrcvd, socket; STRING .
tag input value; the tag parameter to be used for the nowait operation initiated by recv_nw64_. For more information, see Asynchrony and Nowaited Operations (page 34). Errors If an error occurs, the return value is set to -1, and the external variable errno is set to one of the following values: EHAVEOOB There is pending out-of-band data. This must be cleared with a call to recv64_ with the MSG_OOB flag set. (This error does not apply to UDP sockets.) ENOTCONN The specified socket was not connected.
... tosend = sizeof(buffer); status = recv64_(rsock, (char _ptr64*)&buffer[0], tosend, 0); recvfrom The recvfrom function receives data on an unconnected UDP socket or raw socket created for waited operations. C Synopsis #include #include #include #include /* for IPv6 use */
from_ptr input and return value;points, on return, to the remote address and port number (based on the structure sockaddr_in or sockaddr_in6) from which the data is received. from_length input and return value; maintained only for compatibility and should point to a value indicating the size in bytes of the structure (the remote address and port number) pointed to by from_ptr.
/* Notice that fhost below is cast to struct sockaddr * as suggested in the Usage Guidelines */ status = recvfrom(rsock, buffer, tosend, 0, (struct sockaddr *)&fhost, &len); recvfrom64_ The recvfrom64_ function receives data on an unconnected UDP socket or raw socket created for waited operations. C Synopsis #include #include #include #include /* for IPv6 use */
flags input value; specifies how the message is read, and is one of the following messages: MSG_PEEK Read the incoming message without removing it from the queue. 0 No flag; read incoming message normally. from_ptr64 input and return value; on return, points to the remote address and port number (based on the structure sockaddr_in or sockaddr_in6) from which the data is received.
#include #include #include #include /* for IPv6 use */ error = recvfrom_nw (socket, buffer_ptr, buffer_length, flags, r_buffer_ptr, r_buffer_length, tag ); int error, socket; char * buffer_ptr; int buffer_length, flags; struct sockaddr * r_buffer_ptr; int * r_buffer_length; long tag; TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC error := recvfrom_nw (socket, buffer_ptr, buffer_length, flags, r_buffer_ptr, r_buffer_length, tag ); INT(32) STRING .
Errors If an error occurs, the return value is set to -1 and the external variable errno is set to one of the following values: EISCONN The specified socket was connected. ESHUTDOWN The specified socket was shut down. EINVAL An invalid argument was specified. Usage Guidelines • This is a nowait call; it must be completed with a call to the AWAITIOX procedure. For a waited call, use recvfrom.
error = socket_get_info (rsock, (char*) &fhost, len); if (error != 0) { printf ("socket_get_info failed, error %d\n", errno); exit(1) } INET6: the following programming example calls the recvfrom_nw function. In this example, rsock is a socket created by a previous call to socket and fhost is a structure that receives the address of the host from which the data is received. The data is received in buffer: #include #include #include #include #include
char _ptr64 * buffer_ptr64; int buffer_length, r_buffer_length, flags; struct sockaddr * addr; long long tag; TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC error := recvfrom_nw64_ (socket, buffer_ptr64, buffer_length, flags, r_buffer_ptr, r_buffer_length, tag ); INT(32) error, socket; STRING .EXT64 buffer_ptr64; INT(32) buffer_length, flags; INT .EXT r_buffer_ptr(sockaddr_in); INT(32) r_buffer_length; INT(64) tag; error return value; if the call is successful, a zero is returned.
Usage Guidelines • This is a nowait call; it must be completed with a call to the FILE_AWAITIO64_ procedure. For a waited call, use recvfrom64_. • The parameters of the recvfrom_nw64_ function are not compatible with those of the recvfrom64_ function in the 4.3 BSD UNIX operating system. • The length of the received data is specified in the third parameter (count transferred) returned from the FILE_AWAITIO64_ procedure.
C Synopsis #include #include nsent = send (socket, buffer_ptr, buffer_length, flags); int nsent, socket; char *buffer_ptr; int buffer_length, flags; TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC nsent := send (socket, buffer_ptr, buffer_length, flags); INT(32) nsent, socket; STRING .EXT buffer_ptr; INT(32) buffer_length, flags; nsent return value; specifies the number of bytes sent. This is the return value.
EHAVEOOB There is out-of-band data pending. This must be cleared with a call to recv_nw with the MSG_OOB flag set. EHAVEOOB There is out-of-band data pending. This must be cleared with a call to recv_nw with the MSG_OOB flag set. Usage Guidelines See Nowait Call Errors (page 86) for information on checking errors. Example See UDP Client Program (page 219) for an example that calls send. send64_ The send64_ function sends data on a connected socket for waited operations. C Synopsis #include
flags input value; specifies the type of data to be sent, or specifies a routing restriction. flags has one of the following values: MSG_DONTROUTE Send the message only if the destination is located on the local network; do not send the message through a gateway. MSG_OOB Send the data as out-of-band data. This corresponds to the TCP URG flag. 0 Send the message to the destination. If needed, route the message.
TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC error := send_nw (socket, nbuffer_ptr, nbuffer_length, flags, tag); INT(32) STRING .EXT INT(32) INT(32) error, socket; nbuffer_ptr; nbuffer_length, flags; tag; error return value; if the call is successful, a zero is returned. If the call is not successful, —1 is returned. If the call failed, the external variable errno is set as indicated in Errors (page 171).
Errors If an error occurs, the external variable errno is set to one of the following values: EALREADY The send buffer is already full. EMSGSIZE The message was too large to be sent atomically, as required by the socket options. ENOTCONN The specified socket was not connected. ESHUTDOWN The specified socket was shut down. ETIMEDOUT The connection timed out. ECONNRESET The connection was reset by the remote host. EINVAL An invalid flags value was specified.
tag); int error, socket; char _ptr64 *nbuffer_ptr64; int nbuffer_length, flags; long long tag; TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC error := send_nw64_ (socket, nbuffer_ptr64, nbuffer_length, flags, tag); INT(32) error, socket; STRING .EXT64 nbuffer_ptr64; INT(32) nbuffer_length, flags; INT(64) tag; error return value; if the call is successful, a zero is returned. If the call is not successful, —1 is returned.
Errors If an error occurs, the external variable errno is set to one of the following values: EALREADY The send buffer is already full. EMSGSIZE The message was too large to be sent atomically, as required by the socket options. ENOTCONN The specified socket was not connected. ESHUTDOWN The specified socket was shut down. ETIMEDOUT The connection timed out. ECONNRESET The connection was reset by the remote host. EINVAL An invalid flags value was specified.
int error, socket; char *nbuffer_ptr; int nbuffer_length, flags; long tag; TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC error := send_nw2 (socket, nbuffer_ptr, nbuffer_length, flags, tag); INT(32) error, socket; STRING .EXT nbuffer_ptr; INT(32) nbuffer_length, flags; INT(32) tag; error return value; if the call is successful, a zero is returned. If the call is not successful, —1 is returned. If the call failed, the external variable errno is set as indicated in Errors (page 174).
Usage Guidelines • Use send_nw2 on a socket created for nowait operations. The operation initiated by send_nw2 must be completed with a call to the AWAITIOX or AWAITIO procedure (although AWAITIOX is recommended). • To determine the number of bytes that have been transferred as a result of the send_nw2 function, call the socket_get_len call. • For the send_nw2 call, complete the request with a call to AWIATIOX before issuing another function call that uses nbuffer_ptr.
error := send_nw2_64_ (socket, nbuffer_ptr64, nbuffer_length, flags, tag); INT(32) error, socket; STRING .EXT64 nbuffer_ptr64; INT(32) nbuffer_length, flags; INT(64) tag; error return value; if the call is successful, a zero is returned. If the call is not successful, –1 is returned. If the call fails, the external variable errno is set as shown in Errors (page 176). socket input value; specifies the socket number for the socket, as returned by the call to socket_nw.
Usage Guidelines • Use send_nw2_64_ on a socket created for nowait operations. The operation initiated by send_nw2_64_ must be completed with a call to the FILE_AWAITIO64_ procedure. • To determine the number of bytes that are transferred as a result of the send_nw2_64_ function, call the socket_get_len call. • For the send_nw2_64_ call, complete the request with a call to AWIATIOX64 before issuing another function call that uses nbuffer_ptr64.
nsent return value; the number of bytes sent. This is the return value. If this number is less than length, the operation should be retried with the remaining data. If the call is not successful, —1 is returned and the external variable errno is set as indicated in Errors (page 178). socket input value; specifies the socket number for the socket, as returned by the call to the socket function. buffer_ptr input value; points to the data to be sent.
sendto64_ The sendto64_ function sends data on an unconnected UDP socket or raw socket for waited operations. C Synopsis #include #include
Errors If an error occurs, the return value is set to –1, and the external variable errno is set to one of the following values: EACCES Permission denied for broadcast because SO_BROADCAST is not set. EMSGSIZE The message was too large to be sent atomically, as required by the socket options. EISCONN The specified socket was connected. ESHUTDOWN The specified socket was shut down. ENETUNREACH The destination network was unreachable. EINVAL An invalid argument was specified.
INT(32) INT(32) sockaddr_length; tag; error return value; if the call is successful, a zero is returned. If the call is not successful, —1 is returned. If the call failed, the external variable errno is set as indicated in Errors (page 181). socket input value; specifies the socket number for the socket, as returned by the call to socket_nw. buffer_ptr input value; points to the data to be sent. buffer_length input value; the size of the buffer pointed to by buffer_ptr.
• To determine the number of bytes transferred as a result of the sendto_nw function, use the socket_get_len function. • Declare the sockaddr_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 Nowait Call Errors (page 86) for information on error checking.
flags input value; specifies whether the outgoing data should be sent to the destination if routing is required. This parameter can be one of the following messages: MSG_DONTROUTE Send this message only if the destination is located on the local network; do not send the message through a gateway. 0 No flag; send the message to the destination, even if the message must be routed. sockaddr_ptr input value; points to the remote address and port number to which the data must be sent.
sendto_nw64_(socket,(char _ptr64*) bp, sizeof(bp), 0, (struct sockaddr *)&fhost,len,0L); FILE_AWAITIO64_(&ret_fd, (char _ptr64*)&snw, &cc, &ret_tag, 0D,-1); cc = socket_get_len(socket); if (cc < 0) break; bp += cc; }; setsockopt, setsockopt_nw The setsockopt and setsockopt_nw functions set the socket options for a socket. NOTE: In CIP, certain setsockopt and setsockopt_nw operations are not supported or may have different defaults or different behavior.
level input value; the socket level at which the socket option is being managed. The possible values are: SOL_SOCKET Socket-level option. IPPROTO_TCP TCP-level option. IPPROTO_IP IP-level option for INET sockets. IPPROTO_IPV6 IP-level option for INET6 sockets. IPPROTO_ICMP ICMP-level option. IPPROTO_RAW Raw-socket level option. user-protocol Option for a user-defined protocol above IP, such as PUP. user-protocol can be any protocol number other than the numbers for TCP, UDP, IP, ICMP, and RAW.
When level is IPPROTO_IP, the value is: IP_OPTIONS Set IP options for each outgoing packet. optval_ptr is a pointer to a list of IP options and values whose format is as defined in RFC 791. IP_MULTICAST_IF Set the multicast interface IP address (that is, subnet IP address) to which the multicast output is destined. A default interface is chosen if this option is not set or is set to INADDR_ANY. IP_MULTICAST_TTL Set Time-To-Live for multicast datagram. Default TTL is 1.
optlen input value; the length, in bytes, of the list pointed to by optval_ptr. If too small, the error EINVAL is returned. (See Errors (page 188).) tag input value; the tag parameter to be used for the nowait operation initiated by setsockopt_nw.
Errors If an error occurs, the external variable errno is set to one the following values: ENOPROTOOPT The specified option is unknown to the protocol. EINVAL An invalid argument was specified. Usage Guidelines • Use setsockopt on a socket created for waited operations, or setsockopt_nw on a socket created for nowait operations. The operation initiated by P/setsockopt_nw must be completed with a call to the AWAITIOX procedure.
shutdown, shutdown_nw The shutdown and shutdown_nw functions shut down data transfer, partially or completely, on an actively connected TCP socket. C Synopsis #include #include
Usage Guidelines • Use shutdown on a socket created for waited operations, or shutdown_nw on a socket created for nowait operations. The operation initiated by shutdown_nw must be completed with a call to the AWAITIOX procedure. • Because the shutdown function shuts down an active connection, it has no meaning for the UDP or IP protocols. • After a socket is shut down, there is a delay before the port can be reused. This delay occurs so that any stray packets can be flushed from the network.
error return value; if the call is successful, a zero is returned. If the call is not successful, –1 is returned. If the call failed, the external variable errno is set as indicated in Errors (page 191). socket input value; specifies the socket number for the socket, as returned by the call to socket or socket_nw. tag input value; the tag parameter to be used for the nowait operation. Errors EINVAL: An invalid argument was specified. ENOTCONN: The specified socket is not connected.
C Synopsis #include #include
The following considerations apply to this parameter: • The function socket_nw() internally maps the old FLAGS parameter to the corresponding parameters for the FILE_OPEN_(). • The flags parameter is not used for the socket function (waited operations). For the socket_nw function, flags.< bit 8> = 1 indicates a nowaited file open and flags.< bits 12:15> indicates the maximum number of outstanding nowaited I/Os allowed (nowait depth). sync input value; not supported for Guardian sockets.
C Synopsis #include #include #include #include #include /* for IPv6 use */ error = socket_backup(*message, *brother_phandle); int error; struct open_info_message *message; char *brother_phandle; error return value; if the call is successful, a zero is returned. If the call is not successful, –1 is returned. If the call failed, the external variable errno is set as indicated in Errors (page 194).
error = socket_get_info(socket, sockaddr_buffer, buflen); int error, socket; char *sockaddr_buffer; int buflen; TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC error := socket_get_info(socket, sockaddr_buffer, buflen); INT(32) error, socket; STRING .EXT sockaddr_buffer; INT(32) buflen; error return value; if the call is successful, the size of the sockaddr data structure is returned. If the call is not successful, –1 is returned.
bytes_sent = socket_get_len(socket); int bytes_sent, socket; TAL Synopsis ?NOLIST, SOURCE SOCKPROC bytes_sent := socket_get_len(socket); INT(32) bytes_sent, socket; bytes_sent return value; the number of bytes sent from a sendto_nw call or a send_nw2 call. socket input value; the socket specified in the prior sendto_nw or send_nw2 call. Errors There are no errors returned by this call. Usage Guideline Use socket_get_len after a call to AWAITIOX and before a subsequent call to AWAITIOX.
Usage Guidelines • Use socket_get_open_info after creating a socket using the socket or socket_nw functions. Then, immediately checkpoint the data. • Use socket_get_open_info to checkpoint state information to a backup process after a call to AWAITIOX and before subsequent AWAITIOX calls. • The user application must fill in the filenum, flags and sync variables in the open_info_message structure before calling this function.
socket input value; specifies the socket number for the socket, as returned by the call to socket or socket_nw. command input value; specifies the operation to be performed on the socket. Supported operations are listed in Table 16 (page 199). arg_ptr input value; points to the argument for the operation. The pointer type is dependent on the value of command. See Table 16 (page 199) for a list of the pointer types.
• The FIONBIO command is not supported. If this command is selected, the EINVAL error is returned. • If you select FIONREAD for UDP sockets, the number of characters returned is greater than the number of characters received as a result of a call to the recv or recvfrom functions; the increase in characters is equal to sizeof (struct sockaddr_in).
Table 16 Socket I/O Control Operations (continued) Command Pointer Type for arg Description SIOCSIFBRDADDR struct ifreq * Set the broadcast address associated with a subnet device. Returns the error [EOPNOTSUPP]. SIOCGIFBRDADDR struct ifreq * Get the broadcast address associated with a subnet device. SIOCSIFNETMASK struct ifreq * Set the network address mask. SIOCSIFNETMASK specifies which portion of the IP host ID and IP network number should be masked to define a subnet.
C Synopsis #include "netdb.h" void socket_set_inet_name (name_ptr); char *name_ptr; TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC void socket_set_inet_name (name_ptr); STRING .EXT name_ptr; name_ptr input value; points to a null-terminated character string containing the process name of the NonStop TCP/IP or TCP6SAM process that is to be accessed by subsequent calls to socket or socket_nw. Errors No errors are returned for this function.
?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC error := recvfrom_nw (socket, r_buffer_ptr, length, flags, tag ); INT INT .EXT INT(32) socket, length, flags; r_buffer_ptr(sendto_recvfrom_buf); tag; error return value; if the call is successful, a zero is returned. If the call is not successful, –1 is returned. If the call failed, the external variable errno is set as indicated in Errors (page 202). socket input value; specifies the socket number for the socket, as returned by the call to socket_nw.
• The length of the received data is given in the third parameter (count transferred) returned from the AWAITIOX procedure. This length includes the address information given by sizeof(sockaddr_in) at the beginning of the buffer. • Note that the MSG_OOB option is not available. This is a constraint imposed by UDP. UDP does not support out-of-band data. See Nowait Call Errors (page 86) for information on checking errors.
flags input value; specifies how the incoming message must be read, and takes one of the following values: MSG_PEEK Read the incoming message without removing the message from the queue. 0 No flag; read data normally. tag is the tag parameter to be used for the nowait operation initiated by t_recvfrom_nw64_. Errors If an error occurs, the return value is set to -1 and the external variable errno is set to one of the following values: EISCONN The specified socket was connected.
flags INT .EXT sockaddr_ptr(sockaddr); INT(32) tag; error return value; if the call is successful, a zero is returned. If the call is not successful, –1 is returned. If the call failed, the external variable errno is set as indicated in Errors (page 205). socket input value; specifies the socket number for the socket, as returned by a socket_nw call. r_buffer_ptr input and return value; points to the remote address and port number to which the data is to be sent, followed by the data.
t_sendto_nw64_ The t_sendto_nw64_ function sends data on an unconnected UDP socket or raw socket created for nowait operations. This routine is replaced by the sendto_nw64_ routine. C Synopsis #include #include #include
Errors If an error occurs, the external variable errno is set to one of the following values: EMSGSIZE The message was too large to be sent atomically, as required by the socket options. EISCONN The specified socket was connected. ESHUTDOWN The specified socket was shut down. ENETUNREACH The destination network was unreachable. EINVAL An invalid argument was specified. Usage Guidelines • This is a nowait call; it must be completed with a call to the FILE_AWAITIO64_ procedure.
5 Sample Programs This section provides TCP/IP program examples for AF_INET sockets and AF_INET6 sockets. Programs Using AF_INET Sockets This subsection contains a client and server program that use AF_INET sockets. AF_INET Client Stub Routine The first example shows a sample client program that you can build, compile, and run on your system. The program sends a request to and receives a response from the system specified on the command line.
char request[MAXBUFSIZE] = " This is the client's request"; if (argc < 2) { printf("Usage: client \n"); exit (0); } server = argv[1]; /* Clear the server address and sets up server variables. The socket address is a 32-bit Internet address and a 16-bit port number. */ bzero((char *) &serveraddr, sizeof(struct sockaddr_in)); serveraddr.sin_family = AF_INET; /* Obtain the server's IPv4 address. A call to gethostbyname returns IPv4 address only.
/* Convert the server's 32-bit IPv4 address to a dot-formatted Internet address text string. A call to inet_ntoa expects an IPv4 address as input. */ ap = inet_ntoa(serveraddr.sin_addr); printf("Response received from"); if (hp != NULL) printf(" %s", hp->h_name); if (ap != NULL) printf(" (%s)", ap); printf(":\n %s\n", databuf); FILE_CLOSE_((short)s); } AF_INET Server Stub Routine The next example shows a sample server program that you can build, compile, and run on your system.
int int u_short struct hostent const char new_s; dcount; port; *hp; *ap; /* Declares sockaddr_in structures. The use of this type of structure implies communication using the IPv4 protocol. */ struct sockaddr_in serveraddr; struct sockaddr_in clientaddr; int clientaddrlen; char response[MAXBUFSIZE] = " This is the server's response"; /* Creates an AF_INET socket. The socket type SOCK_STREAM is specified for TCP or connection-oriented communication.
IPv4 address as input. */ ap = inet_ntoa(clientaddr.sin_addr); port = ntohs(clientaddr.sin_port); printf("Request received from"); if (hp != NULL) printf(" %s", hp->h_name); if (ap != NULL) printf(" (%s)", ap); printf(" port %d\n\"%s\"\n", port, databuf); /* Send a response to the client.
short IOCheck ( long TOVal ) { /* use a single AWAITIOX() check for all I/O in this pgm return value is FE; sets global tagBack & socket that completed; don't care about buf addr but do want count */ short error; _cc_status CC; completedSocket = -1; CC = AWAITIOX( &completedSocket,,&dcount,&tagBack,TOVal ); /* ignoring possible _status_gt condition */ if( _status_lt( CC ) ) { FILE_GETINFO_( completedSocket,&error ); return error; } else return 0; } int main (int argc,char **argv ) { int s; char databuf[MAXB
while (1) { /* Accept a connection on this socket. The accept call places the client's address in the sockaddr_in structure named clientaddr.*/ clientaddrlen = sizeof(clientaddr); if( accept_nw(s, (struct sockaddr *)&clientaddr, &clientaddrlen, tag) <0) { perror("accept"); exit(3); } if( fe = IOCheck(acceptWait) ) { /* initially, wait -1; maybe change afterwards? */ if( fe == 40 ) { printf( "Timed out after %ld secs wtg Client connect. Terminating.
hp = gethostbyaddr((char *)&clientaddr.sin_addr.s_addr, sizeof(clientaddr.sin_addr.s_addr), AF_INET); /* Convert the client's 32-bit IPv4 address to a dot-formatted Internet address text string. A call to inet_ntoa expects an IPv4 address as input. */ ap = inet_ntoa(clientaddr.sin_addr); port = ntohs(clientaddr.
/* define things */ int fo; int rdstat,nbytes; register int fd; struct sockaddr_in sin; char *buf; char *procname; int nbufs, bsize; int port; struct hostent *host_entry; /* DEBUG(); */ /* open send file */ argc--; argv++; if (argc < 3) goto usage; if ((fo = (open(argv[0],O_RDONLY))) < 0) { printf ("CLIENT: open failed\n"); exit(0); } /* set address according to device name */ argc--; argv++; if ((sin.sin_addr.
nbytes = bsize; /* lets open the process */ printf ("CLIENT: Data is sent with TCPIP process %s \n",procname); (void) socket_set_inet_name (procname); /* lets open the socket */ if ((fd = socket (AF_INET, SOCK_STREAM, 0)) < 0) { perror ("CLIENT: socket"); exit(0); } printf ("CLIENT: Socket # %d opened ... \n", fd); sin.sin_family = AF_INET; sin.
> run Sample Program #pragma nolist #include <$system.ztcpip.param.h> #include <$system.ztcpip.socket.h> #include <$system.ztcpip.in.h> #include <$system.ztcpip.netdb.h> #include #include #include #include #include #include
/* Bind the socket */ if (bind (fd,(struct sockaddr *)&sin, (int)sizeof (sin)) < 0) { perror ("SERVER: bind"); exit (0); } printf ("SERVER: BIND completed ...\n"); if (listen (fd, 5) < 0) { perror ("SERVER: listen"); exit (0); } printf ("SERVER: Listening on socket # %d \n", fd); if ((s2 = accept (fd,(struct sockaddr *)&from, &flen)) < 0) { perror ("SERVER: accept"); exit (0); } printf ("SERVER: Connected ...
#include #include #include #include #include #define INET_ERROR 4294967295 #pragma list /* * The following DEFINES control the behavior of the client.
optlen = sizeof(optval); if (setsockopt(channel,SOL_SOCKET,SO_DONTROUTE, (char *)&optval,optlen) < 0) perror("setsockopt(DONTROUTE)"); #endif #ifdef SETBUF printf("\nExecute SETSOCKOPT to increase socket buffering\n"); optlen = sizeof(optval); optval = 10*1024; if (setsockopt(channel,SOL_SOCKET,SO_RCVBUF, (char *)&optval,optlen) < 0) perror("setsockopt(RCVBUF)"); optlen = sizeof(optval); optval = 10*1024; if (setsockopt(channel,SOL_SOCKET,SO_SNDBUF, (char *)&optval,optlen) < 0) perror("setsockopt(RCVBUF)");
*/ buffer[0] = '?'; while (buffer[0] != '!') { int sent = 0; printf("\nInput (end with !)? "); if (gets(buffer) == NULL) break; if (buffer[0] == 0) continue; tosend = (int)strlen(buffer); retry: printf("\nExecute SEND[TO]\n"); #ifdef CONNECTIONLESS len = sizeof(remote); status = sendto(channel, ((char *)buffer + sent), tosend, 0, (struct sockaddr *)&remote, len); #else status = send(channel, ((char *)buffer + sent), tosend, 0); #endif printf("\nAfter SEND[TO], execute GETSOCKNAME\n"); optlen = sizeof(me); i
#endif printf("Number of chars from recv[from] is %d\n", status); } printf("\nExecute GETPEERNAME fails if CONNECTIONLESS socket\n"); optlen = sizeof(him); if (getpeername(channel,(struct sockaddr *)&him,&optlen) < 0) perror("getpeername"); else printf(" His socket: family=%d port=%d addr=%lx\n", him.sin_family,him.sin_port,him.sin_addr.
chan = socket(AF_INET, SOCK_DGRAM, 0); if (chan == -1){ printf ("echo server: socket failed\n"); exit (0); } /* * Bind it to an Internet Address */ len = sizeof(sin); status = bind(chan, (struct sockaddr *)&sin, len); if (status == -1) perror ("echo server: bind failed"); optlen = sizeof(optval); optval = 1; if (setsockopt(chan,SOL_SOCKET,SO_BROADCAST, (char *)&optval,optlen) < 0) perror("setsockopt"); optlen = sizeof(optval); optval = 20*1024; if (setsockopt(chan,SOL_SOCKET,SO_RCVBUF, (char *)&optval,optle
UDP Program for Sending Multicast Packets The following programming example shows how to use the socket routines in an application that implements multicast for sending: /*#pragma nolist*/ #include "inh" #include "socketh" #include "sckconfh" #include #include #include #include #include #include #include #include #include #include #include #include #prag
portNum = atoi (argv[argNum++]); printf (" PortNum: %i\n", portNum); /* convert string to PORT # */ /* Name of this host */ thishost = argv[argNum++]; if ((temp = gethostbyname (thishost)) != (struct hostent*)NULL) { memmove ((char *)&in_addr_this.s_addr, (char *)temp->h_addr, (size_t)temp->h_length); } else { printf ("gethostbyname failed for %s, error = %d\n", thishost, h_errno); exit (0); } thisaddr = in_addr_this.
if (setsockopt (fd1, IPPROTO_IP, IP_MULTICAST_IF, (char *)&in_addr_this, sizeof(in_addr_this))) perror ("SET MULTI IF error"); exit (0); } if (getsockopt (fd1, IPPROTO_IP, IP_MULTICAST_IF, (char *)&in_addr_gmulti, &getsize)) perror ("GET MULTI IF error"); exit (0); } { { printf ("GET Multicast I/F: %s, size: %d\n", inet_ntoa(in_addr_gmulti), getsize); /* Disable multicast loopback */ loopbkset = 0; if (setsockopt (fd1, IPPROTO_IP, IP_MULTICAST_LOOP, (char *)&loopbkset, sizeof(loopbkset))) perror ("SET MU
/* Close the socket */ FILE_CLOSE_ (fd1); } UDP Program for Receiving Multicast Packets The following programming example shows how to use the socket routines in an application that implements multicast for receiving: #pragma nolist #include "inh" #include "sckconfh" #include "socketh" #include #include #include #include #include #include #include #include #include #include #
/* Port number */ portNum = atoi (argv[argNum++]); printf (" PortNum: %i\n", portNum); /* convert string to PORT # */ /* Name of this host */ thishost = argv[argNum++]; if ((temp = gethostbyname (thishost)) != (struct hostent*)NULL) { memmove ((char *)&in_addr_this.s_addr, (char *)temp->h_addr, (size_t)temp->h_length); } else { printf ("gethostbyname failed for %s, error = %d\n", thishost, h_errno); exit (0); } thisaddr = in_addr_this.
(char *)&ttlget, &getsize)) perror("GET MULTI TTL error"); printf ("GET TTL: %d, size: %d \n",ttlget, getsize); /* Join multicast groups */ multi_req.imr_interface.s_addr = thisaddr; for (i = 1, multiaddr = multiaddr0; i <= IP_MAX_MEMBERSHIPS; i++, multiaddr += MAGIC_NUMBER) { multi_req.imr_multiaddr.s_addr = multiaddr; printf ("ADDing MEMBERSHIP to group: %s or %lx\n", inet_ntoa (multi_req.imr_multiaddr) , multi_req.imr_multiaddr.s_addr); printf (" ON I/F: %s\n", inet_ntoa(multi_req.
j <= IP_MAX_MEMBERSHIPS; j += 3, multiaddr += (MAGIC_NUMBER * 3)) { multi_req.imr_multiaddr.s_addr = multiaddr; printf ("DROP MEMBERSHIP from group: %s or %lx\n", inet_ntoa (multi_req.imr_multiaddr), multi_req.imr_multiaddr.s_addr); printf (" ON I/F: %s\n", inet_ntoa(multi_req.imr_interface)); if (setsockopt (fd1, IPPROTO_IP, IP_DROP_MEMBERSHIP, (char *)&multi_req, sizeof(multi_req))) { perror ("DROP MEMBER error"); printf (" error code: %x Hex (%d.
END BLOCK; ?PUSHLIST,NOLIST,SOURCE $SYSTEM.SYSTEM.RTLDECS(convert) ?POPLIST ?PUSHLIST,NOLIST,SOURCE $SYSTEM.ZTCPIP.SOCKPROC( connect ? ,gethostbyname ? ,gethostbyaddr ? ,getservbyname ? ,get_errno ? ,inet_addr ? ,paramcapture ? ,recv ? ,send ? ,socket ? ) ?POPLIST ?PUSHLIST,NOLIST,SOURCE $SYSTEM.SYSTEM.EXTDECS0( ? DEBUG ? FILE_CLOSE_ ? ) ?POPLIST ?PUSHLIST,NOLIST,SOURCE $SYSTEM.SYSTEM.CREDECS( cre_terminator_ ? ,cre_log_message_ ? ) ?POPLIST ?PUSHLIST,NOLIST,SOURCE $SYSTEM.SYSTEM.
BEGIN INT count_read := 0; INT error := 0; IF (error:=CRE_LOG_MESSAGE_(input_buffer:0,,buffer_length,count_read)) THEN BEGIN CALL DEBUG; END; input_buffer[count_read] := 0; -- Null Termination. RETURN count_read; END; PROC echo_main MAIN; BEGIN INT(32) bytes_from_term := 0; INT(32) total_received := 0; INT(32) nrcvd := 0; INT(32) sock := -1; INT(32) bytes_returned := 0; STRING .EXT startup_msg[0:50]; STRING .EXT buf[0:1024]; INT .EXT param_msg = buf; STRING .EXT host_name; STRUCT .
THEN BEGIN CALL paramcapture(param_msg); END; -- Create an open socket to do IO on.
total_received := 0; DO BEGIN nrcvd := 0; IF ((nrcvd := recv( sock ,buf[total_received] ,$OCCURS(buf)-total_received ,0)) < 0) THEN BEGIN PRINT_ERROR(recv_error); CALL CRE_TERMINATOR_(CRE^Completion^fatal); END; IF (nrcvd = 0) THEN BEGIN term_msg(con_close); CALL CRE_TERMINATOR_(CRE^Completion^warning); END; total_received := total_received + nrcvd; END UNTIL total_received >= bytes_from_term; buf[total_received] := 0; -- Null Termination.
#include #include #include #include
the addrinfo structure. */ while (cur_info != NULL) { if ((s = socket(cur_info->ai_family,cur_info->ai_socktype,0))<0){ perror("socket"); freeaddrinfo(server_info); exit(3); } /* Connect to the server using the address in the addrinfo structure named cur_info. */ if ((err = connect(s,cur_info->ai_addr,(int)cur_info->ai_addrlen))<0){ perror("connect"); cur_info = cur_info->ai_next; continue; } break; } /* Free all addrinfo structures.
AF_INET6 Server Stub Program This example shows a sample server program that you can build, compile, and run on your system. The program receives requests from and sends responses to client programs on other systems.
/* Declare a sockaddr_storage structure named clientaddr. The use of this type of structure enables your program to be protocol independent. */ sockaddr_storage clientaddr; char response[MAXBUFSIZE] = " This is the server's response"; /* Create an AF_INET6 socket. The socket type SOCK_STREAM is specified for TCP or connection-oriented communication. */ if ((s = socket(AF_INET6, SOCK_STREAM, 0)) < 0) { perror("socket"); exit (0); } /* Clear the server address bzero((char *) &serveraddr, serveraddr.
/* Obtains the client's name with a call to getnameinfo using the address in the sockaddr_storage structure named clientaddr. The NI_NAMEREQD flag directs the routine to return a hostname for the given address. */ ni = getnameinfo((struct sockaddr *)&clientaddr, clientaddrlen, addrbuf, sizeof(addrbuf), port, sizeof(port), NI_NUMERICHOST|NI_NUMERICSERV); if (ni == 0) printf(" (%s) port %s", addrbuf, port); printf(":\n\"%s\"\n", databuf); /* Sends a response to the client.
A Well-Known IP Protocol Numbers Table 17 provides a list of commonly used IP protocol numbers, together with the names you can use for them in your application programs. These protocols are provided in the file $SYSTEM.ZTCPIP.PROTOCOL. For other protocol numbers, refer to RFC 1010, “Assigned Numbers.
Table 19 Port Numbers for Host-Specific Functions Port Number Protocol C Name(s) of Service or Function 69 UDP tftp 77 TCP rje 79 TCP finger 87 TCP link, ttylink 95 TCP supdup 105 TCP csnet-ns 117 TCP uucp-path 119 TCP nntp, usenet 123 UDP ntp 1524 TCP ingreslock Table 20 Port Numbers for UNIX-Specific Services Port Number Protocol C Name(s) of Service or Function 512 TCP exec UDP biff, comsat TCP login UDP who, whod TCP shell, cmd (no passwords used) UDP sysl
B Socket Errors This appendix summarizes the socket errors that can be returned in the external variable errno by the routines in the socket interface library. Socket errors start at base 4000. The errors returned in the external variable h_errno are not contained in this appendix. For those errors, see the error descriptions under the gethostbyaddr and gethostbyname functions in Chapter 4 (page 81).
EADDRNOTAVAIL (4115) EADDRNOTAVAIL Cause A call to bind or bind_nw specified an address-port number combination that is not available on the local host. Effect The bind or bind_nw call failed. Recovery Specify an address and port number that are valid for this system. EAFNOSUPPORT (4113) EAFNOSUPPORT Cause The “Family” attribute in the PROVIDER object is not configured correctly.
Cause Either an application attempted to write directly to the NonStop TCP/IPv6 or NonStop TCP/IP process, or an internal error occurred in one of the socket routines. Effect The operation failed. Recovery Direct writes to the NonStop TCP/IP or NonStop TCP/IP process are not permitted; use the socket calls. However, if the problem appears to be an internal socket error, contact your service provider.
Recovery Retry the call with a valid destination address. EEXIST (4017) EEXIST Cause Object exists. An existing object was specified in an inappropriate context, such as attempting to add a route entry that had already been added. Effect The call failed. Recovery Retry the call with a valid object name. EFAULT (4014) EFAULT Cause The system encountered a memory access fault in attempting to use an argument of the call. Effect The call failed. Recovery Contact your service provider.
Recovery Ensure that you have specified a valid hostname or address. If so, ensure that the remote host can be reached from the local host. EINPROGRESS (4102) EINPROGRESS Cause Operation now in progress. A connect_nw call was attempted on a non-blocking socket where connect_nw had already been called on that socket. Effect The call failed. Recovery Wait and retry the operation.
Effect The call failed. Recovery Correct the call. For a connected socket, use send, send_nw, recv, or recv_nw. EMFILE (4024) EMFILE Cause The network manager attempted to add too many routes. Effect The call failed. Recovery Close some files and retry the call. EMSGSIZE (4106) EMSGSIZE Cause The message was too large to be sent automatically, as required by the socket options. Effect The call failed. Recovery Reduce the message size and retry the call.
Recovery Close the sockets using the close call. Reestablish the connections using the socket, bind, connect, and accept calls and retry the call. ENETUNREACH (4117) ENETUNREACH Cause The specified remote network was unreachable. Effect The interface is down. Recovery Retry the call. ENOBUFS (4121) ENOBUFS Cause There was not enough buffer space available to complete the call. Effect The call failed. Recovery Retry the call.
Recovery Reduce the number of connect and/or listen calls. ENOTCONN (4123) ENOTCONN Cause The specified socket was not connected. Effect The call failed. Recovery Ensure that the socket is connected and retry the operation. ENOTSOCK (4104) ENOTSOCK Cause A socket operation was attempted on an object that is not a socket. Effect The call failed. Recovery Specify a valid socket and retry the operation.
Effect The call failed. Recovery Use the Subsystem Control Facility (SCF) ALTER command (or its programmatic equivalent), rather than socket calls. See the TCP/IP Configuration and Management Manual or the TCP/IP Management Programming Manual for a description of the ALTER command. EPFNOSUPPORT (4112) EPFNOSUPPORT Cause The specified protocol family is not supported. It has not been configured into the system or no implementation for it exists. The protocol family is used for the Internet protocols.
Cause A numeric specification in the call is not within the allowable range. Effect The call failed. Recovery Correct the faulty specification and retry the call. ESHUTDOWN (4124) ESHUTDOWN Cause The operation could not be performed because the specified socket was already shut down. Effect The call failed. Recovery Reopen the remote socket using the open, bind, and accept calls. Reestablish the connection using a call to connect or connect_nw.
EWOULDBLOCK (4101) EWOULDBLOCK Cause A recv(MSG_OOB) or recv_nw(MSG_OOB) call was issued with the MSG_OOB flag set, but there was no out-of-band data to read. Effect The call failed. Recovery Execute a recv or recv_nw call without setting the MSG_OOB flag. If the recv or recv_nw call fails with an EHAVEOOB value in errno, call recv or recv_nw with the MSG_OOB flag set.
Index Symbols $SYSTEM.ZTCPIP.HOSTS See HOSTS file , 26 $SYSTEM.ZTCPIP.
initiating, 43 keep alive, 185 passive, 26 passively checking for, socket routine, 91, 94 setting maximum pending TCP, 153 Control operations, socket, 193 Converting service name to port number, 76 CRE, requirements for TAL, 87 CRE-dependent routines, 81 CRE-independent routines, 81 Creating a socket, 35 D Data structures arpreq, 64, 65 hostent, 66 if_nameindex, 67 ifreq, 68 in6_addr, 70 in_addr, 69 ip_mreq, 70 ipv6_mreq, 71 netent, 71 open_info_message, 72 protent, 73 rtentry, 74 send_nw_str, 75 sendto_re
in accept_nw library routine, 92 in accept_nw1 library routine, 95 in accept_nw2 library routine, 96 in accept_nw3 library routine, 98 in bind, bind_nw library routines, 100 in connect, connect_nw library routines, 103 in gethostname library routine, 114 in getpeername, getpeername_nw library routines, 122 in getsockname, getsockname_nw library routines, 127 in if_indextoname library routine, 132 in recvfrom library routine, 159 in recvfrom64_ library routine, 161 in recvfrom_nw library routine, 163, 202 in
ESOCKTNOSUPPORT error in socket, socket_nw library routines, 193 Ethernet interface, 69 ETIMEDOUT error in connect, connect_nw library routines, 103 in recv, recv_nw library routines, 155 in recv64_, recv_nw64_ library routines, 157 in send library routine, 167 in send64_ library routine, 169 in send_nw library routine, 171 in send_nw2 library routine, 174 in send_nw2_64_ library routine, 176 in send_nw64_ library routine, 173 F fcntl system call, 34 File names, resolving for TCP/IP, 29 File-system errors,
Interface request structure, 67, 68 Internet address combining network and local portions, 135 converting format of, 133, 134, 137, 139 getting by hostname, 110 getting hostname for, 109 in data structure, 66, 69, 70, 71, 77, 78, 79 of socket remote connection, 121 port number associated, 78, 79 separating local portion, 135 separating network portion, 136 sockaddr_in, 241 socket bound to, 126 IP defined, 25 programming using raw sockets, 41 IP protocol numbers commonly used, 241 well-known, 241 IP_ADD_MEMB
getting socket, 128 setting socket, 184 Order, host or network, 32 Out-of-band data pending, 33 P Packet to broadcast address, 188 Packets routed through gateway, 74 Parallel Library TCP/IP, 23 PARAMH file, 243 perror, not supported for TAL sockets, 85 PF_INET, 54 PF_INET6, 54 Point-to-point link, 69 Pointers, TAL handling of, 87 Port number for service, 124 from service name, 76 in data structure, 78, 79 of remote connection, 121 overview, 31 service on, 125 socket bound to, 126 well-known, 241 PORTCONF f
Server basic program steps, 37 defined, 25 invoked by LISTNER, 31, 37 primary, 28 secondary, 28 starting or running, 29 tertiary, 28 Services converting names of, 76 getting name from port number, 125 port number for, 124 types of, 25 SERVICES file getservbyname, 125 getservbyport, 126 port numbers in, 241 relationship with LISTNER, 31 setsockopt function, 184 setsockopt_nw function, 184 shutdown function definition, 189 use of, 36 shutdown_nw function, 189 sin_family field, 78, 79 SO_BROADCAST socket optio
socket, 191 socket_backup, 193 socket_get_info, 194 socket_get_len, 195 socket_get_open_info , 196 socket_ioctl, 197 socket_ioctl_nw, 197 socket_nw, 191 socket_set_inet_name, 200 t_recvfrom_nw, 201 t_recvfrom_nw64_, 203 t_sendto_nw, 204 t_sendto_nw64_, 206 waited operations, 85 socket_backup function, 193 socket_get_info function, 194 socket_get_len function, 195 socket_get_open_info function, 196 socket_ioctl function, 197 socket_ioctl_nw function, 197 socket_nw function, 191 socket_set_inet_name function,
in getipnodebyaddr library routine, 115 in getipnodebyname library routine, 117 U UDP defined, 25 nowait operations, 41 port and broadcasting, 100 receiving data on nowait socket, 161, 164, 201, 203 receiving data on waited socket, 158, 160 selecting a socket, 31 sending data on nowait socket, 180, 182, 204, 206 sending data on waited socket, 177, 179 socket control limitation, 199 UNIX differences from Guardian environment, 32 signals, 33 Urgent data pending, 33 User protocol socket level (TCP/IP), 185 Us