HP NonStop IPX/SPX Programming Manual Abstract This manual describes how to develop socket applications for the HP NonStop™ Internetwork Packet Exchange/Sequenced Packet Exchange (IPX/SPX) subsystem. Product Version NonStop IPX/SPX D40 and G06 Supported Release Version Updates (RVUs) This manual supports D40.00 and all subsequent D-series RVUs and G06.00 and all subsequent G-series RVUs until otherwise indicated by its replacement publication.
Document History Part Number Product Version 528022-001 NonStop IPX/SPX D40 and G06 Published April 2004
HP NonStop IPX/SPX Programming Manual Glossary Index Figures What’s New in This Manual vii Manual Information vii New and Changed Information Tables vii About This Manual ix Intended Audience ix How to Use This Manual ix Where to Go for More Information Documentation Book Maps xi Notation Conventions xii x 1. Introduction to NonStop IPX/SPX Supported NetWare Protocols Interfaces 1-2 The Socket Library 1-3 Servers and Clients 1-4 Processes 1-5 1-1 2.
3. Programming Using the Socket Interface (continued) Contents 3. Programming Using the Socket Interface (continued) Process Names 3-13 Service Names (SAP Table) 3-13 4. Data Structures Library Headers 4-1 NonStop IPX/SPX Data Structures nv_addr 4-3 sockaddr 4-4 sockaddr_nv 4-7 4-2 5.
. Library Routines (continued) Contents 5.
A. Well-Known IP Protocol Numbers Contents A. Well-Known IP Protocol Numbers B.
B. Socket Errors (continued) Contents B. Socket Errors (continued) EPIPE (4032) B-11 EPROTOTYPE (4107) B-11 ERANGE (4034) B-11 ESHUTDOWN (4124) B-12 ESOCKTNOSUPPORT (4110) ESRCH (4003) B-12 ETIMEDOUT (4126) B-12 B-12 Glossary Index Figures Figure i. Figure ii. Figure 1-1. Figure 1-2. Figure 2-1. Figure 2-2. Figure 2-3. Figure 2-4. Figure 2-5. Figure 3-1. Figure 4-1. Figure 4-2. Figure 4-3.
Tables Contents Tables Table 2-1. Table 2-2. Table 2-3. Table 2-4. Table 3-1. Table 3-2. Table 3-3. Table 3-4. Table 3-5. Table 3-6. Table 4-1. Table 4-2. Table 5-1. Table 5-2. Table 5-3. Table 5-4. Table 5-5. Table A-1. Table B-1.
What’s New in This Manual Manual Information HP NonStop IPX/SPX Programming Manual Abstract This manual describes how to develop socket applications for the HP NonStop™ Internetwork Packet Exchange/Sequenced Packet Exchange (IPX/SPX) subsystem. Product Version NonStop IPX/SPX D40 and G06 Supported Release Version Updates (RVUs) This manual supports D40.00 and all subsequent D-series RVUs and G06.00 and all subsequent G-series RVUs until otherwise indicated by its replacement publication.
What’s New in This Manual New and Changed Information HP NonStop IPX/SPX Programming Manual—528022-001 viii
About This Manual This manual describes application development for the NonStop Internetwork Packet Exchange/Sequenced Packet Exchange (IPX/SPX) subsystem using the HP socket library routines. This edition of the HP NonStop IPX/SPX Programming Manual is dual-threaded and describes the following: System Type Product Version Supported RVUs HP NonStop K-series systems NonStop IPX/SPX D40 D40.00 and later D4x RVUs HP NonStop S-series systems NonStop IPX/SPX F40 G06.
Where to Go for More Information About This Manual • • • • • Section 5, Library Routines, provides the syntax and semantics of the function calls in the socket library. It also describes the programmatic interface to the Service Advertising Protocol (SAP). Section 6, Sample Programs, provides sample client and server programs that use the interfaces to IPX, SPX, SPXII, and SAP.
Documentation Book Maps About This Manual • • 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 HP NonStop Kernel operating system.
Notation Conventions About This Manual Figure ii. NonStop IPX/SPX Book Map for D-Series RVUs IPX/SPX User's Manual IPX/SPX Configuration and Management Manual IPX/SPX Programming Manual VSTAB02.vsd Notation Conventions General Syntax Notation The following list summarizes the notation conventions for syntax presentation in this manual. UPPERCASE LETTERS. Uppercase letters indicate keywords and reserved words; enter these items exactly as shown. Items not enclosed in brackets are required.
General Syntax Notation About This Manual each side of the list, or horizontally, enclosed in a pair of brackets and separated by vertical lines. For example: LIGHTS [ ON ] [ OFF ] [ SMOOTH [ num ] ] K [ X | D ] address-1 { } 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.
Notation for Messages About This Manual Line Spacing. If the syntax of a command is too long to fit on a single line, each continuation line is indented three spaces and is separated from the preceding line by a blank line. This spacing distinguishes items in a continuation line from items in a vertical list of selections. For example: ALTER [ / OUT file-spec / ] CONTROLLER [ , attribute-spec ]...
Notation for Messages About This Manual { } Braces. A group of items enclosed in braces is a list of all possible items that can be displayed, of which one is actually displayed. The items in the list might 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: LBU { X | Y } POWER FAIL process-name State changed from old-objstate to objstate { Operator Request. } { Unknown. } | Vertical Line.
Notation for Messages About This Manual HP NonStop IPX/SPX Programming Manual—528022-001 xvi
1 Introduction to NonStop IPX/SPX This section provides an overview of the NonStop IPX/SPX subsystem. This section also introduces the HP NonStop socket library and the Service Advertising Protocol (SAP), with which you can develop programs that communicate over a Novell IPX/SPX protocol network. The NonStop IPX/SPX subsystem allows communications to take place between heterogeneous systems over a Novell NetWare network.
Interfaces Introduction to NonStop IPX/SPX • • NetWare Core Protocol (NCP) allows client workstations to access NetWare servers and services and corresponds to the OSI model Transport and Session Layers. NCP operates in conjunction with the underlying IPX network-level protocol. NCP is not available for NonStop IPX/SPX application development.
The Socket Library Introduction to NonStop IPX/SPX • • SAP interface allows a HP fault-tolerant server application to advertise its services to workstations on the NetWare network. The SAP interface is open to NonStop IPX/SPX application development. NetWare application program interfaces (APIs) allow applications to access NetWare services such as printing or filing. NonStop IPX/SPX provides a subset of the NetWare APIs for the LAN Print Spooler for the NetWare process only.
Introduction to NonStop IPX/SPX Servers and Clients Note. Throughout this manual, socket refers to the Berkeley Software Distribution (BSD) definition of a socket: an end point for communication. IPX or SPXII socket refers to the socket address portion of the IPX address. For more information on IPX addresses, see Section 2, Addressing.
Introduction to NonStop IPX/SPX Processes Processes The NonStop IPX/SPX subsystem contains the IPX Manager (IPXMGR) process and one or more IPX Protocol (IPXPROTO) processes. IPXPROTO processes are implemented as process pairs, which provide support for the NetWare protocols (described in Addressing on page 2-1). Each IPXPROTO process is associated with exactly one LAN port (for D-series RVUs) or one SLSA LIF (for G-series RVUs).
Introduction to NonStop IPX/SPX HP NonStop IPX/SPX Programming Manual—528022-001 1 -6 Processes
2 Addressing This section describes the supported NetWare protocols and interfaces to the IPX, SPX, and SAP protocols Application Programmatic Interfaces (APIs) Supported NetWare Protocols NonStop IPX/SPX supports the following NetWare protocols: IPX, SPX, SPXII, RIP, SAP, and NCP (for a brief description of the protocols, see Supported NetWare Protocols on page 1-1). Figure 2-1 shows the Novell NetWare protocol suite in relation to the OSI service layers.
Supported NetWare Protocols Addressing protocols (SPX, SPXII, NCP, and SAP) use IPX to transport messages to their destination. IPX, SPX, NCP, and SAP do not use a checksum; therefore, they cannot guarantee end-to-end data integrity. Higher-level protocols and applications must ensure the reliable transmission of the data. SPXII permits the use of a checksum, which you can enable or disable using the setsockopt or setsockopt_nw routines described in Section 5, Library Routines.
Supported NetWare Protocols Addressing Destination Address IPX address of the destination node. Source Address IPX address of the source node. Data is the data. Table 2-1. IPX Packet Type Field Identification Packet Type Value (Hexadecimal) Higher-Level Protocol 0x01 RIP 0x04 SAP 0x05 SPX and SPXII 0x11 NCP 0x14 NetBIOS IPX Addresses An IPX address uniquely identifies a node on an IPX internetwork. An IPX address is 12 bytes long and consists of the three fields shown in Figure 2-3.
Supported NetWare Protocols Addressing Node identifies a specific machine within a network. The node field is usually related to the physical address of the network adapter. On Ethernet LANs, the node field is the MAC address of the LAN adapter or controller. The combination of the network and node fields is used by IPX to transmit packets within a NetWare internetwork. On a NonStop system, the node address is the same as the MAC address of the LAN controller.
Supported NetWare Protocols Addressing Table 2-2. IPX Socket Number Usage Socket Numbers (Hexadecimal) Use 0x0002 Xecho (debugging tool) 0x0451 NCP 0x0452 SAP Table 2-3. SPXII Socket Number Usage Socket Numbers (Hexadecimal) Use 0x4000 - 0x4FFF Dynamic sockets used by SPXII for application binds 0x7000 - 0x70FF TELSERV listener 0x7100 - 0x71FF ODBC listener 0x7200 - 0x72FF RSC listener.
Supported NetWare Protocols Addressing Figure 2-4. SPXII Packet Header Format Conn Control Data Stream Type Source Connection ID Destination Connection ID Sequence Number Acknowledge Number Allocation Number 1 Byte 1 Byte 2 Bytes 2 Bytes 2 Bytes 2 Bytes 2 Bytes Data .. . VST0204.vsd The SPXII packet header fields include: Conn. (Connection) Control specifies whether the packet is a system packet, an acknowledge data packet (ACK packet), or a data packet.
Supported NetWare Protocols Addressing On the NonStop system, the SAP table is maintained by the IPXPROTO process. The SCF command STATUS SERV returns information about the SAP table maintained by the IPXPROTO process. Server applications use the SAP protocol to perform the following: • • • Add an entry for the service in the SAP table maintained by the IPXPROTO process. The entry is then propagated to other NetWare servers by the IPXPROTO process by broadcasts every 60 seconds.
Interface Libraries Addressing Interface Libraries Most of the NonStop IPX/SPX interfaces are organized into libraries. The libraries are coded in C, and a HP TAL version is available through a set of header files. NonStop IPX/SPX provides the following interfaces: • • • Socket interface to IPX and to SPXII. SAP interface allows a NonStop server to advertise its presence on the network and to look for other services.
Interface Libraries Addressing Application processes request the NonStop IPX/SPX application to create a socket when needed; the application specifies the type of service desired. The NonStop IPX/SPX software returns a socket number that the application uses to reference the new socket. The application then (optionally) binds the socket to a specific local address and port, and sends or receives data on the socket.
Interface Libraries Addressing HP NonStop IPX/SPX Programming Manual—528022-001 2- 10
3 Programming Using the Socket Interface This section describes the structure of client and server programs that use the socket library routines, and presents some general programming considerations. It also provides the information you need in order to port existing programs from another implementation of IPX/SPX, or to create application programs. For detailed descriptions of all the routines in the socket library, refer to Section 5, Library Routines.
Nowait I/O Programming Using the Socket Interface In most cases, the parameters for these calls are identical to those of the corresponding waited calls, with the addition of extra parameters for NonStop Kernel requirements. The exceptions to this rule are accept_nw2, recvfrom_nw, send_nw2, sendto_nw, t_recvfrom_nw, and t_sendto_nw, which have different sets of parameters. After performing a nowait I/O operation, your program must check for the completion with a call to the AWAITIOX procedure call.
Programming Using the Socket Interface Differences Between UNIX and HP Implementations Differences Between UNIX and HP Implementations The HP socket routines also differ from the 4.3 BSD UNIX socket routines in the following ways: • • • • The select routine is not supported. Instead, use the nowait I/O capability to test I/O completion by issuing the AWAITIO[X] call on specific sockets. Include files are in either the $SYSTEM.ZTCPIP or $SYSTEM.
IPX and SPXII Address Socket Numbers Programming Using the Socket Interface IPX and SPXII Address Socket Numbers Table 3-1 lists the IPX socket numbers, which are preassigned to specific services when accessed from IPX, and the name or names of each service as it is used in application programs. Table 3-1. IPX Socket Number Usage Socket Numbers* (Hexadecimal) Use 0x0002 Xecho (debugging tool) 0x0451 NCP 0x0452 SAP *The socket number is equivalent to a TCP/IP port.
Programming Using the Socket Interface Basic Steps for Programs Basic Steps for Programs This subsection summarizes the basic steps performed by client and server programs for the IPX and SPXII protocols. Important considerations for each type of program are provided later in this subsection. Client Program The basic steps performed by a client program are: 1. Designate the NonStop IPX/SPX process name (optional). 2. Create a socket. 3.
Programming Using the Socket Interface Basic Steps for Programs Connecting a Socket The connect function associates a remote address and port number with the socket. For SPXII, connect issues a request for an active connection. For IPX, no active connection exists. The connect call serves as a means to permanently specify the remote address and port number (or protocol number) so that each call to transfer data does not need to specify this information.
Programming Using the Socket Interface Basic Steps for Programs 8. Start data transfer (if step 5 was done, use the new socket created in that step). 9. Shut down the socket (optional for SPXII; not done for IPX). For SPXII only, call shutdown or FILE_CLOSE. 10. Close the socket. For servers, some of the calls or call requirements vary depending on the way the server operates.
Programming Using the Socket Interface Basic Steps for Programs 3. Accepts the connection on the new socket. For nowait operations, a program must issue the following sequence of calls to perform these functions: accept_nw AWAITIOX socket_nw AWAITIOX accept_nw2 AWAITIOX Server Programs Started by Waited and Nowait Operations In the NonStop IPX/SPX socket library, most of the socket function calls used for data transmission have waited and nowait versions.
Programmatic Interface to IPX and SPXII Programming Using the Socket Interface Programmatic Interface to IPX and SPXII The format of data transferred is known to the client and server only, and is not interpreted by the subsystems or protocols. Because application programs run at the IPX and SPXII levels, they can pass appropriate header parameters to the socket function calls and send or receive data without assembling and disassembling the headers.
SPXII Client and Server Programs Programming Using the Socket Interface The nowait versions of the socket calls require the program to provide a tag parameter to identify the particular operation. When AWAITIOX is called, it returns the tag that was passed to it in the corresponding nowait socket call. Table 3-4. SPXII—Nowait Client and Server Steps Client Server 1. Optionally, set NonStop IPX/SPX process name (socket_set_nv_name). 1. Optionally, set NonStop IPX/SPX process name (socket_set_nv_name).
IPX Client and Server Programs Programming Using the Socket Interface IPX Client and Server Programs Table 3-5 shows the steps performed by an IPX client and an IPX server in waited operations. Table 3-5. IPX—Waited Client and Server Steps Client Server 1. Optionally, set NonStop IPX/SPX process name (socket_set_nv_name). 1. Optionally, set NonStop IPX/SPX process name (socket_set_nv_name). 2. Create a socket (socket). 2. Create a socket (socket). 3.
IPX Client and Server Programs Programming Using the Socket Interface Table 3-6 lists the steps performed by an IPX client and an IPX server in nowait operations. Table 3-6. IPX—Nowait Client and Server Steps Client Server 1. Optionally, set NonStop IPX/SPX process name (socket_set_nv_name). 1. Optionally, set NonStop IPX/SPX process name (socket_set_nv_name). 2. a. Create a new socket (socket_nw)with (flags & 0xF1) nowait set. 2. a. Create a new socket (socket_nw)with (flags & 0xF1) nowait set.
Programming Using the Socket Interface Programming Considerations Programming Considerations When programming your applications, you should consider the following naming convention for the processes and for the handling of buffers in data transfers. Process Names If you are running more than one NonStop IPXPROTO process in a system and wish to locate all processes by name, the recommended form is $ZNVx, where x is a letter or a numeric digit.
Programming Using the Socket Interface Service Names (SAP Table) HP NonStop IPX/SPX Programming Manual—528022-001 3- 14
4 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 Section 5, Library Routines. Library Headers For NonStop IPX/SPX, the declarations of the functions in the socket library are provided in C programming language only.
NonStop IPX/SPX Data Structures Data Structures NonStop IPX/SPX Data Structures Most data structures are common to the socket library and reside in the header files subvolume $SYSTEM.ZTCPIP. Table 4-2 lists the NonStop IPX/SPX data structures, and indicates the C header file in which each structure is declared and the type of call that uses that structure. Table 4-2. Summary of NonStop IPX/SPX Data Structures and C Header Files Structure Tag Header File Type of Call That Uses Structure nv_addr nv.
nv_addr Data Structures nv_addr The nv_addr data structure specifies the IPX address. It is defined in the nv.h header file. struct nv_addr { unsigned char s_net[4]; unsigned char s_host[6]; unsigned short s_port; }; s_net[4] network address portion of the IPX address for the host. s_host[6] node address portion of the IPX address for the host. s_port IPX socket (port) number portion of the IPX address for the host. Note.
sockaddr Data Structures sockaddr This structure, which is defined in the netdb.h header file, is a pointer to the sockaddr_nv structure. It makes the NonStop IPX/SPX software compatible with other implementations. When you pass a parameter of this type to a socket routine, the actual fields filled or read are those based on the sockaddr_nv structure. For example, in a NonStop IPX/SPX, the coding is as follows: #include "$system.ztcpip.nvh" ... struct sockaddr_nv snv; ...
sockaddr Data Structures Figure 4-1 compares the sockaddr and sockaddr_in data structures that exist for RVUs before the D30 RVU. Both data structures refer to the address family in the 2 low-order bytes, to the port in the third and fourth bytes, and to the Internet address in the 4 high-order bytes. However, the sockaddr data structure refers to the port and Internet address as a pointer to a character string.
sockaddr Data Structures Figure 4-2 compares the sockaddr and sockaddr_in data structures that exist for RVUs beginning with the D30 RVU. Figure 4-2.
sockaddr_nv Data Structures sockaddr_nv The sockaddr_nv data structure is used by many socket function calls. It is defined in the nv.h header file. struct sockaddr_nv { short snv_family; struct nv_addr snv_addr; unsigned char snv_reserved[2]; }; snv_family address family AF_NV, as defined in the socket header file. snv_addr IPX address. snv_reserved[2] reserved for future use.
sockaddr_nv Data Structures Figure 4-3 shows the nv_addr and sockaddr_nv data structures. Figure 4-3.
5 Library Routines This section contains the syntax and semantics for the socket library routines provided by the NonStop IPX/SPX software products. The Service Advertising Protocol (SAP) library routines are described at the end of this section. 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 on page 3-1.
CRE-Independent Socket Library Library Routines CRE-Independent Socket Library The CRE-Independent socket library routines are provided in three versions for data storage. Two are non-native versions, one for the large-memory model and one for the wide-data model. The large-memory model routines are in the file $SYSTEM.ZTCPIP.LNETINDL. The wide-data model routines are in $SYSTEM.ZTCPIP.LNETINDW. The native-linkable version is in the file LNETINDN.
Summary of Routines Library Routines Table 5-1. Socket Routines (page 2 of 2) Name and Description Page Function Page ipx_ntoa converts an address from binary format to hexadecimal format.
Syntax and Semantics of Socket Library Routines Library Routines Syntax and Semantics of Socket Library Routines This subsection describes each routine in the socket library. The routines are listed alphabetically.
Interfacing TAL Programs to the Socket Library Library Routines the meaning of each error according to the type of call and the circumstances in which your program issues the call. Note. The perror function is not supported for TAL sockets. Nowait Call Errors The nowait versions of the routines return the error in the file-system variable error, which you can obtain by calling the FILE_GETINFOBYNAME_ procedure immediately following the call to AWAITIOX.
Procedure Prototypes Library Routines 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.
Usage/Bind Considerations Library Routines ° ° INT PROC get_errno; INT PROC get_h_errno; Note that these restrictions imply that the following features are not available in the C run-time library subset: • • _MAIN, that is, startup processing, general initialization. Heap management (‘malloc’, ‘calloc’, ‘realloc’, ‘free’) is available only through the Common Run-Time Environment (CRE) user heap management routines. Refer to the CRE Programming Manual for details.
CRE Considerations Library Routines executable, a CRE-independent native mode socket library, LNETINDN is provided. LNETINDN is a linkable object. The TAL-callable functions, paramcapture() and allparamcapture(), have been removed from the D40 socket library. These functions provided a mechanism to save run-time parameters used by the socket library (=TCPIP^PROCESS^NAME, =TCPIP^HOSTS^FILE, and so forth). Because the DEFINE mechanism is now used instead of PARAM, this functionality is no longer required.
Native Mode C/C++ Issues Library Routines 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. The extensions pragma also must be specified when the c89 compiler is used for systype=guardian compiles.
accept Library Routines accept The accept function checks for connections on an existing waited socket. When a connection request arrives, accept creates a new socket to use for data transfer and accepts the connection on the new socket. C Synopsis #include #include #include
accept Library Routines 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 will be blocked until the operation completes. For nowait I/O, use accept_nw and accept_nw2. For TCP and SPXII server applications, a call to bind and listen must precede a call to accept.
accept_nw Library Routines accept_nw The accept_nw function checks for connections on an existing nowait socket. It is designed to be followed first by a call to socket_nw to create a new socket, then a call to accept_nw2 to accept the connection on the new socket. C Synopsis #include #include #include
accept_nw Library Routines remote client’s IP address in the from_ptr sockaddr struct. This is an input parameter. tag is 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.
accept_nw Library Routines exit (0); /* Call AWAITIOX */ /* Before calling accept_nw, program must call bind_nw and * listen. A call to AWAITIOX must follow the bind_nw call. */ flen = sizeof(from); cc = accept_nw(fd1, (struct sockaddr *)&from, flen, t); if (cc < 0) { perror (“Server: Accept failed.”) exit (0); } else { /* Call AWAITIOX using socket fd1 and tag t. */ ... if ((fd2 = socket_nw(AF_NV, SOCK_STREAM,0,021,0)) < 0) { perror (“Server Socket 2 create failed.
accept_nw2 Library Routines accept_nw2 The accept_nw2 function accepts a connection on a new socket created for nowait data transfer. Before calling this procedure, a program should call accept_nw on an existing socket, then call socket_nw to create the new socket to be used by accept_nw2. C Synopsis #include #include #include
accept_nw2 Library Routines 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. ERSCH The socket specified in the new_socket parameter was invalid. Close the socket using the FILE_CLOSE call. Repeat the accept_nw, socket_nw and accept_nw2 sequence of calls.
bind, bind_nw Library Routines bind, bind_nw The bind and bind_nw functions associate a socket with a specific local IPX address data structure. C Synopsis #include #include #include
bind, bind_nw Library Routines address_len is a value indicating the size in bytes of the IPX address data structure pointed to by address_ptr. If set to 0, IPXPROTO chooses a BSD socket on the application’s behalf. tag is the tag parameter to be used for the nowait operation initiated by bind_nw. Errors If an error occurs, the external variable errno is set to one of the following values: EADDRNOTAVAIL The specified IPX address data structure was not available on the local host.
bind, bind_nw Library Routines */ memset(&snv, 0, sizeof(snv)); snv.snv_family = AF_NV; snv.snv_addr s_port = WELL_KNOWN_PORT; if (bind (fd, (struct sockaddr *)&snv, sizeof (snv)) < 0) { perror (“SERVER: Bind failed.”); exit (1); } /* Bind call succeeded.
connect, connect_nw Library Routines connect, connect_nw The connect and connect_nw functions connect the specified socket to a remote socket. For SPXII, these functions request an active connection. For IPX, they specify the destination address for the socket. C Synopsis #include #include #include
connect, connect_nw Library Routines address_len should be a value indicating the size in bytes of the IPX address data structure, pointed to by address_ptr. tag is the tag parameter to be used for the nowait operation initiated by connect_nw. 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. EISCONN The specified socket was already connected.
connect, connect_nw Library Routines remote.snv_addr s_net[2] = 0x01; remote.snv_addr s_net[3] = 0x01; remote.snv_addr s_host[0] = 0x07; remote.snv_addr s_host[1] = 0x00; remote.snv_addr s_host[2] = 0x7E; remote.snv_addr s_host[3] = 0x00; remote.snv_addr s_host[4] = 0x1E; remote.snv_addr s_host[5] = 0x17; remote.snv_addr s_port = 0xaaaa; if (connect (fd,(struct sockaddr)&remote,sizeof(remote)) <0) { perror (“Client failed to connect to remote host.”) exit (0); } printf (“CLIENT:Connected ...
getpeername, getpeername_nw Library Routines getpeername, getpeername_nw The getpeername and getpeername_nw functions get the IPX address data structure of the remote host to which the specified socket is connected. C Synopsis #include #include #include
getpeername, getpeername_nw Library Routines address_len_ptr is maintained only for compatibility and should point to a value indicating the size in bytes of the IPX address data structure pointed to by address_ptr. tag is 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.
getsockname, getsockname_nw Library Routines getsockname, getsockname_nw The getsockname and getsockname_nw functions get the IPX address data structure to which a socket is bound. C Synopsis #include #include #include
getsockname, getsockname_nw Library Routines address_len_ptr is maintained only for compatibility and should be a value indicating the size in bytes of the IPX address data structure pointed to by address_ptr. tag is 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: EINVAL An invalid argument was specified.
getsockopt, getsockopt_nw Library Routines getsockopt, getsockopt_nw The getsockopt and getsockopt_nw functions return the socket options for a socket. C Synopsis #include #include #include
getsockopt, getsockopt_nw Library Routines level is the socket level at which the socket option is being managed. The only possible socket-level option value is SOL_SOCKET. optname is the socket option name. Possible values are: SO_ERROR Socket error. SO_LINGER Get the value of the SO_LINGER flag. For details, see setsockopt, setsockopt_nw on page 5-49. SO_KEEPALIVE Get the value of the SO_KEEPALIVE flag. For details, see setsockopt, setsockopt_nw on page 5-49 SO_TYPE Returns socket type.
ipx_addr Library Routines ipx_addr The ipx_addr function converts an address format from hexadecimal format to binary format. C synopsis #include p_addr = ipx_addr (addr_ptr); struct nv_addr * p_addr; char *addr_ptr; TAL synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC p_addr := ipx_addr (addr_ptr); INT(32) p_addr ; STRING .EXT addr_ptr; p_addr is a pointer to the IPX address in binary format. This is the return value. This address is a pointer to the structure sockaddr_nv.
ipx_ntoa Library Routines ipx_ntoa The ipx_ntoa function converts an address from binary format to hexadecimal format. C synopsis #include #include asc_ptr = ipx_ntoa (pIn); struct nv_addr * pIn; char *asc_ptr; TAL synopsis ?NOLIST, SOURCE SOCKPROC asc_ptr := ipx_ntoa (pIn; INT(32) INT asc_ptr; .EXT pIn(ipx_addr); asc_ptr points to a null-terminated character string containing the IPX address in hexadecimal format. All numbers are expressed in hexadecimal format.
listen Library Routines 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 IPX/SPX implementation, the maximum pending connections is always 5. A call to listen must precede a call to accept or accept_nw. C Synopsis #include #include #include
recv, recv_nw Library Routines recv, recv_nw The recv and recv_nw functions receive data on a connected socket. C Synopsis #include #include
recv, recv_nw Library Routines buffer_ptr points, on completion, to the data received. length is the size of the buffer pointed to by buffer_ptr. flags specifies the type of data to be read, and is one or more of the following: MSG_PEEK Read the incoming message without removing it from the input queue. 0 No flag; read data normally. tag is the tag parameter to be used for the nowait operation initiated by recv_nw.
recv, recv_nw Library Routines • The sending side of a connection indicates end-of-file by closing or shutting down its socket. The receiving side recognizes end-of-file when the recv or recvfrom calls have 0 bytes in their length-of-buffer field. This is standard practice, not specific to HP’s socket library implementation. You are responsible for handling this condition. For information about error checking, see Nowait Call Errors on page 5-5.
recvfrom Library Routines recvfrom The recvfrom function receives data on an unconnected IPX socket created for waited operations. C Synopsis #include #include #include
recvfrom Library Routines flags 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_ptr points, on return, to the IPX address data structure from which the data is received. from_length is maintained only for compatibility and should point to a value indicating the size in bytes of the remote IPX address data structure pointed to by from_ptr.
recvfrom_nw Library Routines recvfrom_nw The recvfrom_nw function receives data on an unconnected IPX socket created for nowait operations. C Synopsis #include #include #include
recvfrom_nw Library Routines r_buffer_ptr is not used by the recvfrom_nw call. Call socket_get_info on page 5-59 to get the socket address (parameter sockaddr_buffer). A dummy parameter must still be passed to satisfy the recvfrom_nw call. r_buffer_length is no longer used by the recvfrom_nw call to determine the r_buffer_ptr size since r_buffer_ptr is no longer used; however, recvfrom_nw still requires a valid value for this parameter.
recvfrom_nw Library Routines Example In the following 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 #include ... struct sockaddr_nv fhost; int buffsize,len,rsock; char buffer [8*1024]; short error, rsock2; long tag; ...
send Library Routines send The send function sends data on a connected socket. C Synopsis #include #include #include nsent = send (socket, buffer_ptr, buffer_length, flags); int nsent, socket, buffer_length, flags; char *buffer_ptr; TAL Synopsis ?NOLIST, SOURCE SOCKDEFT ?NOLIST, SOURCE SOCKPROC nsent := send (socket, buffer_ptr, buffer_length, flags); INT socket, buffer_length, flags; STRING .EXT buffer_ptr; nsent specifies the number of bytes sent. This is the return value.
send Library Routines 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. 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.
send_nw2 Library Routines send_nw2 The send_nw2 function sends data on a connected socket. Unlike the send and send_nw calls, the send_nw2 call does not store the number of bytes sent in the data buffer. Therefore, the send_nw2 call does not require the application to allocate 2 bytes in front of its data buffer to receive the number of bytes sent. Instead, the application should call socket_get_len to obtain the number of bytes sent. C Synopsis #include #include
send_nw2 Library Routines flags specifies the type of data to be sent, or specifies a routing restriction. flags has one of the following values: MSG_DONTROUTE Send this message only if the destination is located on the local network; do not send the message through a gateway. 0 Send normal data. tag is the tag parameter to be used for the nowait operation initiated by send_nw2.
send_nw2 Library Routines char *snw; int cc, count = bp - &buf [0]; errno = 0; ... for (bp = &buf [0]; count > 0; count -= cc) { send_nw2 (socket, bp, count, 0, 0L); AWAITIOX (&ret_fd, (char *)&snw, &cc, &ret_tag, -1L); cc = socket_get_len(s); if (cc < 0) break; bp += cc; }; Before the call to send_nw2, the program creates a socket. The socket number is saved in the variable socket. The pointer bp points to the data to be sent. The length of the buffer is count.
sendto Library Routines sendto The sendto function sends data on an unconnected IPX socket created for waited operations. C Synopsis #include #include #include
sendto Library Routines flags flags is not used; it must be set to zero. sockaddr_ptr points to the IPX address data structure to which the data is sent. sockaddr_length is maintained only for compatibility and should be a value indicating the size, in bytes, of the IPX address data structure pointed to by sockaddr_ptr.
sendto_nw Library Routines sendto_nw The sendto_nw function sends data on an unconnected UDP socket or raw socket created for nowait operations. C Synopsis #include #include #include
sendto_nw Library Routines flags 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 points to the remote address and port number to which the data is to be sent.
setsockopt, setsockopt_nw Library Routines setsockopt, setsockopt_nw The setsockopt and setsockopt_nw functions set the socket options for a socket. C Synopsis #include #include #include
setsockopt, setsockopt_nw Library Routines level is the socket level at which the socket option is being managed. The possible values are: SOL_SOCKET Socket-level option. NVPROTO_SPX SPX-level option optname is the socket option name. When the value of level is SOL_SOCKET, The possible setsockopt values are: SO_LINGER Allows graceful close of a socket. Socket will stay connected for l_linger number of seconds after it would normally close. SO_KEEPALIVE Keeps connection from ever timing-out.
setsockopt, setsockopt_nw Library Routines Table 5-2. Types and Lengths of Socket Option Values Socket Option Type SO_LINGER Struct linger { short int l_onoff; /*boolean*/ short int l_linger;/*time*/ } ; SO_KEEPALIVE Integer (Boolean) SPX_IPXCHKSUM Integer (Boolean) SPX_OPTIONNEG Integer (Boolean) SPX_RCVWINSIZE Integer 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.
shutdown, shutdown_nw Library Routines 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
shutdown, shutdown_nw Library Routines tag is the tag parameter to be used for the nowait operation initiated by shutdown_nw. Errors If an error occurs, the external variable errno is set to one of the following values: EINVAL An invalid value was passed for the how parameter. ENOTCONN The specified socket was not connected or already shut down. Usage Guidelines • • • • Use shutdown on a socket created for waited operations, or shutdown_nw on a socket created for nowait operations.
socket, socket_nw Library Routines socket, socket_nw The socket function creates a socket for waited operations; the socket_nw function creates a socket for nowait operations. C Synopsis #include #include
socket, socket_nw Library Routines socket_type specifies the semantics of communication. It must be one of the following values: SOCK_STREAM Create a socket (either TCP or SPXII). SOCK_DGRAM Create a socket (either UDP or IPX). SOCK_RAW Create a raw socket for access to the raw IP protocol level. To create a raw socket, the process access ID of the requesting application must be in the SUPER group (user ID 255,nnn). protocol TCP/IP: protocol is the specific IP number.
socket, socket_nw Library Routines • • • If a nowait depth greater than zero is specified, the nowait versions of the socket routines must be used in all subsequent operations on the socket. For nowait operations on a socket, set a nowait depth of 2 to allow pending simultaneous reads and writes. SETMODE 30 is called by socket_nw only if (flags & 0200) is false. sync is not supported for HP sockets. It must always be set to zero.
socket_backup Library Routines socket_backup The socket_backup function returns data to the backup process of a NonStop process pair, after the primary process has checkpointed the data using the socket_get_open_info function. This function is designed to allow user applications to establish a backup open to an IPX/SPX process. This function is called by the backup user application. C Synopsis #include #include #include #include
socket_backup Library Routines Usage Guideline The user need only use checkpoint on the open information for the listening socket, because all open sockets are closed as a result of the backup application takeover and an ECONNRESET returned to all operations on these sockets. The application is then responsible for end-to-end resynchronization of the data stream. Upon takeover, the backup process is only required to post a new listen on the existing (checkpointed) socket by issuing a call to accept_nw().
socket_get_info Library Routines socket_get_info The socket_get_info function returns the sockaddr data structure and the sockaddr length received after a recvfrom_nw call. C Synopsis #include #include #include #include
socket_get_info Library Routines Errors If an error occurs, the variable error is set to one of the following values: 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. EINVAL An invalid argument was specified.
socket_get_len Library Routines socket_get_len The socket_get_len function returns the number of bytes sent following a sendto_nw or send_nw2 call. C Synopsis #include #include bytes_sent = socket_get_len(socket); int bytes_sent, socket; TAL Synopsis ?NOLIST, SOURCE SOCKPROC bytes_sent := socket_get_len(socket); INT bytes_sent, socket; bytes_sent is the number of bytes sent from a sendto_nw call or a send_nw2 call. socket is the socket specified in the prior sendto_nw or send_nw2 call.
socket_get_open_info Library Routines socket_get_open_info The socket_get_open_info function is used by the primary process in a NonStop IPX/SPX process pair to get parameters following a socket or socket_nw call. C Synopsis #include #include #include error = socket_get_open_info(*message); int error; struct open_info_message *message; error is the return value. If the call is successful, a zero is returned. If the call is not successful, -1 is returned.
socket_ioctl, socket_ioctl_nw Library Routines socket_ioctl, socket_ioctl_nw The socket_ioctl and socket_ioctl_nw functions perform a control operation on a socket. C Synopsis #include #include #include #include
socket_ioctl, socket_ioctl_nw Library Routines arg_ptr points to the argument for the operation. The pointer type is dependent on the value of command. For a list of the pointer types, see Table 5-3. tag is the tag parameter to be used for the nowait operation initiated by socket_ioctl_nw. Errors If an error occurs, the external variable errno is set to one of the errors listed in Appendix B, “Socket Errors”; the possible errors depend on the value of command.
socket_ioctl, socket_ioctl_nw Library Routines • For SIOCGIFNUM, aliases are not included in the count. For information on error checking, see Nowait Call Errors on page 5-5. Socket I/O Control Operations Table 5-3 gives the I/O control operations that can be specified in command, the corresponding pointer types for arg_ptr, and descriptions of the commands. The definitions of the structures pointed to by arg_ptr are provided in Section 4, Data Structures. Table 5-3.
Library Routines socket_ioctl, socket_ioctl_nw printf(“Interface %d: %s\n”,i,ifr[i].ifr_name); ...
socket_set_nv_name Library Routines socket_set_nv_name The socket_set_nv_name function sets the IPXPROTO process name. C Synopsis #include short socket_set_nv_name( char *pName ); TAL Synopsis ?SOURCE SAPAPID PROC SOCKET_SET_NV_NAME( pName ), LANGUAGE C; STRING .EXT pName; EXTERNAL; *pName points to a null-terminated character string containing the process name of the IPXPROTO process that is to be accessed by subsequent calls to socket or socket_nw.
Service Advertising Protocol (SAP) Library Routines Library Routines Service Advertising Protocol (SAP) Library Routines This subsection describes programmatic access to the Service Advertising Protocol (SAP). SAP Description SAP allows service nodes, such as file servers, print servers, and database servers, to register their services and addresses in SAP tables maintained by each server. The registration is done via SAP broadcasts every 60 seconds.
SAP Description Library Routines Function Call Purpose sap_stop or sap_stop_nw Deletes an entry from the SAP table in the IPXPROTO process. sap_info or sap_info_nw Returns 0 or more SAP entries from the SAP table in the IPXPROTO process. You might have to execute this call more than once to read the entire SAP table if it is too large to fit into the sap_info buffer. sap_close Terminates a session between an application and the IPXPROTO process for SAP.
SAP Description Library Routines SAP Header Files Applications that add an entry to the SAP table must compile the header files listed below. Header files are in the $SYSTEM.ZIPXPRO subvolume.
netware_set_name Library Routines netware_set_name The netware_set_name function identifies the IPXPROTO process to be opened by the next sap_open call. C Synopsis #include short netware_set_name( char *pName); TAL Synopsis ?SOURCE sapapid PROC netware_set_name( pName ), LANGUAGE C; STRING .EXT pName; EXTERNAL; pName is a character pointer to the name of the IPXPROTO process opened by subsequent sap_open calls.
sap_close Library Routines sap_close The sap_close function closes the file descriptor associated with an IPXPROTO process. C Synopsis #include short sap_close ( short fd, unsigned long *pError ); TAL Synopsis ?SOURCE sapapid PROC sap_close ( fd, pName ), LANGUAGE C; INT fd; STRING .EXT pName; EXTERNAL; fd is the file descriptor of the IPXPROTO process being closed. *pError is the file system error returned if the function call fails with the value -1.
sap_info, sap_info_nw Library Routines sap_info, sap_info_nw The sap_info and sap_info_nw calls return 0 or more SAP entries of the specified type. C Synopsis #include #include #include
sap_info, sap_info_nw Library Routines TAL Synopsis ?SOURCE sapapid ?SOURCE zipxtal ?SOURCE zspic INT PROC sap_info_nw ( fd, pError, serverType, pBuffer, bufferLen, moreFlag, tag), LANGUAGE C; INT fd; INT(32) .EXT pError; INT serverType; STRING .EXT pBuffer; INT bufferLen; INT moreFlag; INT(32) tag; EXTERNAL; ?SECTION sap_info INT PROC sap_info ( fd, pError, serverType, pBuffer, bufferLen, moreFlag), LANGUAGE C; INT fd; INT(32) .EXT pError; INT serverType; STRING .
sap_info, sap_info_nw Library Routines serverType (continued) 0474 ODBC server 05C8 to 05D0 Reserved for HP use 05D1 to 05D2 Services and servers using RSC. Reserved for HP customers. *pBuffer is a pointer to output buffer that contains the 0 or more SAP entries returned. bufferLen is the buffer length, specified by programmer. Range: 60 bytes to 32,767 bytes. moreFlag returns the value 1 if there are more SAP entries than fit in the *pBuffer buffer.
sap_info, sap_info_nw Library Routines ( fd , &SapError , -1 , (char *) sapInfo , 400 , moreFlag ); if (error) { return -1; } /* /* /* /* /* /* in, file number */ out, error code */ in, server types, (-1 = all) */ out, output buffer */ in, byte length of output buffer */ in, SAP flag */ /* Look at SapError for error code */ /* error */ moreFlag = sapInfo->flag; numEntries = sapInfo->sapcount; if (numEntries == 0) { /* There are no SAP entries */ } else { pEntry = &sapInfo->info; for ( i=0; i
sap_open Library Routines sap_open The sap_open function opens the IPXPROTO process. C Synopsis #include short fn = sap_open ( unsigned long *pError , short nowait_depth , short sync_or_receive_depth , short options ); TAL Synopsis ?SOURCE sapapid INT fn = PROC sap_open ( pError, nowait_depth, sync_or_receive_depth , options), LANGUAGE C; INT(32) .
sap_start, sap_start_nw Library Routines sap_start, sap_start_nw The sap_start and sap_start_nw functions add a new entry to the SAP table. Each entry consist of a server name, server type, and IPX socket number.
sap_start, sap_start_nw Library Routines fd is the socket number for the socket. *pError is the file system error returned if the function call fails with the value -1. Errors are listed in the Guardian Procedure Errors and Messages Manual. pServerName is the 48-character server name. HP recommends that you name the server after the Guardian process name, such as $NYC. The characters listed in Table 5-5 are not valid in a NetWare server name, and hexadecimal values less than 0x21 or greater than 0x7d.
sap_stop, sap_stop_nw Library Routines sap_stop, sap_stop_nw The sap_stop function removes a specified entry from the SAP table. C Synopsis #include short sap_stop ( short fd , unsigned long *pError , char *pServerName , short serverType ); short sap_stop_nw ( short fd , unsigned long *pError , char *pServerName , short serverType , long tag ); TAL Synopsis ?SOURCE sapapid INT PROC sap_stop ( fd, pError, pServerName, serverType ) , LANGUAGE C; INT fd; INT(32) .EXT perror; STRING .
sap_stop, sap_stop_nw Library Routines *pError is the file system error returned if the function call fails with the value -1. Errors are listed in the Guardian Procedure Errors and Messages Manual. pServerName Pointer to the 48-character server name to be removed from the SAP table. serverType is a hexadecimal integer representing the server type as listed previously in Table 5-4. serverSocket is the IPX socket address for the service on the local server.
sap_stop, sap_stop_nw Library Routines HP NonStop IPX/SPX Programming Manual—528022-001 5- 82
6 Sample Programs This section contains sample programs that use the socket library routines defined in Section 5, Library Routines, and that follow the guidelines in Section 3, Programming Using the Socket Interface. Note. For details on how to compile and bind programs written in the HP C or TAL programming languages, refer to the C/C++ Programmer’s Guide or the TAL Reference Manual, respectively.
Client and Server Programs Using SPXII Sample Programs int sock, newsock; int bytesReceived; int fromlen; char recvbuf[DATA_BUF_SIZE]; /* * Specify the name of the NonStop IPX/SPX * Protocol Process if required. */ socket_set_nv_name("$NV2A"); /* * Open a socket. */ if ((sock = socket(AF_NV, SOCK_STREAM, 0)) < 0) { perror("SPX Server: socket failure"); exit(1); } memset(&snv, 0, sizeof(snv)); snv.snv_family = AF_NV; snv.snv_addr.
Client and Server Programs Using SPXII Sample Programs break; } if (bytesReceived == 0) { /* received end of file */ printf("SPX Server: received EOF\n"); FILE_CLOSE_((short)newsock); break; } printf("SPX Server: received %d bytes\n", bytesReceived); } } } Sample SPXII Client /* * Sample SPX client program. This example connects * to a server that is waiting on a "well known" port. */ #include #include #include #include #include #include #include
Sample SAP Programs Sample Programs snv.snv_addr.s_host[0] snv.snv_addr.s_host[1] snv.snv_addr.s_host[2] snv.snv_addr.s_host[3] snv.snv_addr.s_host[4] snv.snv_addr.s_host[5] = = = = = = 0x08; 0x00; 0x8E; 0x00; 0x2E; 0x18; snv.snv_addr.s_port = WELL_KNOWN_PORT; /* * Connect to remote. */ if (connect(sock, (struct sockaddr *)&snv, sizeof(snv)) < 0) { perror("SPX Client: connect failure"); exit(1); } printf("SPX Client: connected to port 0x%hx\n", snv.snv_addr.s_port); /* * Send data to remote.
Sample SAP Programs Sample Programs #define PROCESS_NAME "$NV3A" main(int argc, char *argv[]) { struct sockaddr_nv snv; char buf[DATA_BUF_SIZE]; int bytesSent; int sock; nvaddr_t *pNvaddr; nvaddr_t *find_server(char *pServer, short type); socket_set_nv_name(PROCESS_NAME); /* * Look for server in the SAP table. */ pNvaddr = find_server(SERVER_NAME, SERVER_TYPE); if (pNvaddr == NULL) { fprintf(stderr, "SPX Client: server %s not found\n", SERVER_NAME); exit(0); } /* * Open a socket.
Sample SAP Programs Sample Programs close(sock); exit(0); } /* End of main() */ #define SAP_BUF_SIZE ((4 * sizeof(zipx_ddl_sapentry_def)) + 4) nvaddr_t * find_server(char *pServer, short type) { short fnum; short moreFlag = 1; short numEntries; short i; unsigned long error; static char buff[SAP_BUF_SIZE]; zipx_ddl_infosap_def *sapinfo = (zipx_ddl_infosap_def *)buff; zipx_ddl_sapentry_def *pEntry = 0; NETWARE_SET_NAME(PROCESS_NAME); if ((fnum = SAP_OPEN(&error, 0, 1, 0)) < 0) return (nvaddr_t *)NULL; w
Sample SAP Programs Sample Programs #include #include #include #include #include #include #define #define #define #define
Sample SAP Programs Sample Programs /* * Wait for a connection request. */ printf("SPX Server: waiting for connection request\n"); fromlen = sizeof(from); newsock = accept(sock, (struct sockaddr *)&from, &fromlen); if (newsock < 0) { perror("SPX Server: accept failure"); stop_advertising(sapfnum, SERVER_NAME, SERVER_TYPE); break; } printf("SPX Server: connected to port 0x%hx\n", from.snv_addr.s_port); for (;;) { /* * Receive data until either an EOF or error is received.
Client and Server Programs Using IPX Sample Programs stop_advertising(short fnum, char *pServer, short type) { unsigned long error; (void)SAP_STOP(fnum, &error, pServer, type); (void)SAP_CLOSE(fnum, &error); return; } /* End of stop_advertising() */ Client and Server Programs Using IPX This subsection contains simple client programs and server programs that call the socket library routines to communicate using the IPX protocol. IPX Client Program /* * Sample IPX client program.
Client and Server Programs Using IPX Sample Programs snv.snv_addr.s_net[1] snv.snv_addr.s_net[2] snv.snv_addr.s_net[3] = 0x00; = 0x00; = 0x00; snv.snv_addr.s_host[0] snv.snv_addr.s_host[1] snv.snv_addr.s_host[2] snv.snv_addr.s_host[3] snv.snv_addr.s_host[4] snv.snv_addr.s_host[5] = = = = = = snv.snv_addr.s_port = WELL_KNOWN_PORT; 0x08; 0x00; 0x8E; 0x00; 0x2E; 0x18; /* * Send data to remote. Note that the number of bytes * sent could be less than DATA_BUF_SIZE.
Client and Server Programs Using IPX Sample Programs * Open a socket. */ sock = socket(AF_NV, SOCK_DGRAM, 0); if (sock < 0) { perror("socket failure"); exit(1); } /* * IPX Protocol Process will * fill in host and network portions * of the address */ memset(&snv, 0, sizeof(snv)); snv.snv_family = AF_NV; snv.snv_addr.s_port = WELL_KNOWN_PORT; /* * Bind to the socket that we intend to receive data on.
Sample Programs Client and Server Programs Using IPX HP NonStop IPX/SPX Programming Manual—528022-001 6- 12
A Well-Known IP Protocol Numbers Table A-1 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 A-1.
Well-Known IP Protocol Numbers HP NonStop IPX/SPX Programming Manual—528022-001 A- 2
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. Note that 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 Section 5, Library Routines.
EACCES (4013) Socket Errors EACCES (4013) EACCES Cause. A call to bind or bind_nw specified an address or port number that cannot be assigned to a nonprivileged user. Only applications whose process access ID is in the SUPER group (user ID 255,n) can bind a socket to a well-known port. Effect. The bind or bind_nw call failed. Recovery. Specify another port number or address, or rerun the application with a process access ID in the SUPER group (user ID 255,n). EADDRINUSE (4114) EADDRINUSE Cause.
EALREADY (4103) Socket Errors EALREADY (4103) EALREADY Cause. An operation is already in progress. For accept_nw and connect_nw calls, there is already an outstanding call on the socket. For the send_nw call, the send buffer is already full (see the SO_SNDBUF option of the setsockopt, setsockopt_nw on page 5-49 call for increasing the size of the send buffer). Effect. The call failed. Recovery. Wait for the operation to complete and retry the call. EBADF (4009) EBADF Cause.
ECONNREFUSED (4127) Socket Errors ECONNREFUSED (4127) ECONNREFUSED Cause. The remote host rejected the connection request. This error usually results from an attempt to connect to a service that is inactive on the remote host. Effect. The connect call failed. Recovery. Start the server on the remote host. Close the local socket. Reestablish the connection using the socket, bind, and connect calls. ECONNRESET (4120) ECONNRESET Cause. The peer process reset the connection before the operation completed.
EFAULT (4014) Socket Errors 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. EHOSTDOWN (4128) EHOSTDOWN Cause. The destination host is present, but it is not responding. Effect. The call failed. Recovery. Correct the problem in the destination host and retry the call. EHOSTUNREACH (4129) EHOSTUNREACH Cause. No route to host.
EINTR (4004) Socket Errors EINTR (4004) EINTR Cause. While a process was in the sleep mode waiting for an event, it received an unexpected signal, not the wait-for event. Effect. The call failed. Recovery. Retry the call. EINVAL (4022) EINVAL Cause. An argument passed to one of the socket functions was invalid. Effect. The call failed. Recovery. Corrective action depends on the function and the circumstances. For a list of valid arguments, see the description of the function that caused the error.
EISCONN (4122) Socket Errors EISCONN (4122) EISCONN Cause. A call to sendto, t_sendto_nw, recvfrom, recvfrom_nw, or t_recvfrom_nw was made on a socket that was connected. 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.
ENETDOWN (4116) Socket Errors ENETDOWN (4116) ENETDOWN Cause. The network is down. The operation encountered a dead network. Effect. The call failed. Recovery. Contact the network manager. ENETRESET (4118) ENETRESET Cause. The network dropped the connection because of a reset. The host you were connected to crashed and rebooted. Effect. The call failed, and all connections to the specified remote host were closed. Recovery. Close the sockets using the close call.
ENOMEM (4012) Socket Errors ENOMEM (4012) ENOMEM Cause. Insufficient memory was available to complete the call. Effect. The call failed. Recovery. Retry the call. ENOPROTOOPT (4108) ENOPROTOOPT Cause. A call to getsockopt, getsockopt_nw, setsockopt, or setsockopt_nw specified an option that was unknown to the specified protocol. Effect. The call failed. Recovery. Specify the correct operation or protocol and retry the call. ENOSPC (4028) ENOSPC Cause.
ENOTSOCK (4104) Socket Errors 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. ENXIO (4006) ENXIO Cause. The call specified an unknown device or the request was outside of the device capabilities. Effect. The call failed. Recovery. Correct the call using a known interface device or configure the desired interface device and retry the call.
EPFNOSUPPORT (4112) Socket Errors 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. Effect. The call failed. Recovery. Specify AF_NV for NonStop IPX/SPX and retry the operation. EPIPE (4032) EPIPE Cause. A write or send call was attempted on a local socket that had been previously closed with the shutdown call. Effect.
ESHUTDOWN (4124) Socket Errors 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. ESOCKTNOSUPPORT (4110) ESOCKTNOSUPPORT Cause. The socket type specified in a call to socket or socket_nw is not supported by the NonStop IPX/SPX software. Effect. The call failed. Recovery.
ETIMEDOUT (4126) Socket Errors Table B-1.
ETIMEDOUT (4126) Socket Errors HP NonStop IPX/SPX Programming Manual—528022-001 B -14
Glossary The following glossary defines terms used both in this manual and in other NonStop TCP/IP and IPX/SPX manuals. Both industry-standard terms and HP terms are included; HP terms are marked as such. Because this is a glossary for HP NonStop IPX/SPX as a whole, not all terms listed here are used in this particular manual. Access Control Server (ACS). An optional HP system process that can be used to grant or deny workstation access to the RSC services on the HP system.
Asynchronous Transfer Mode (ATM) Glossary Asynchronous Transfer Mode (ATM). A transfer mode in which the information is organized into cells. ATM. See Asynchronous Transfer Mode (ATM). attribute. In DSM, a characteristic of an entity. For example, two attributes of a communications line might be its hop count and its retry count. In a token-oriented interface based on SPI, an attribute of an object is usually expressed as either a simple token or as a field within an extensible structured token.
DARPA (Defense Advanced Projects Research Agency) Glossary DARPA (Defense Advanced Projects Research Agency). The government agency that funded research and experimentation with the ARPANET and DARPA Internet. Formerly called ARPA. DDN (Defense Data Network). Used to loosely refer to the MILNET and ARPANET and the TCP/IP protocols they use. More literally, it is the MILNET and associated parts of the Internet that connect military installations. definition files.
EGP Glossary EGP. (Exterior Gateway Protocol) The protocol used by a gateway in one autonomous system to advise the Internet addresses of networks in that autonomous system to a gateway in another autonomous system. Every autonomous system must use EGP to advertise network reachability to the core gateway system. empty. response record. In DSM programmatic interfaces, a response record containing only a return token with a value that means “no more response records.” EMS.
FINGER Glossary FINGER. A protocol providing a method for retrieving status information about one or all the users on a particular system. fixed structure. In DSM programmatic interfaces, a multifield structure declared for the value of a simple token. Fields cannot be added to fixed structures in later RVUs. forwarding distributor. An EMS distributor process that sends selected event messages to an EMS collector on another network node. See also distributor. FTP (File Transfer Protocol).
Interactive command Glossary Interactive command. In DSM, a command entered by a human operator rather than by a program. International Organization for Standardization. See ISO. Institute of Electrical and Electronics Engineers. See IEEE. Internet. Physically, a collection of packet-switching networks interconnected by gateways along with protocols that allow them to function logically as a single, large, virtual network.
IXF Glossary IXF. See Information Xchange Facility (IXF). LAN (local area network). Any physical network technology that operates at high speed (usually tens of megabits per second through several gigabits per second) over short distances (up to a few thousand meters). LAN Print Spooler for NetWare. A HP print process that delivers print spooler jobs to NetWare print queues. LIF. See logical interface (LIF). Level 2.
manager process Glossary manager process. In DSM, a HP subsystem process with which the SCP management process communicates to control a particular data communications subsystem. MILNET. (Military Network) Originally part of the ARPANET, MILNET was partitioned in 1984 to make it possible for military installations to have reliable network service whereas the ARPANET continued to be used for research.
Network Basic I/O System Glossary Network Basic I/O System. (NetBIOS) An interface between programs executing in the workstation and an attached LAN. NFS. (Network File System). A protocol developed by SUN Microsystems that uses IP to allow a set of cooperating computers to access each other’s file systems as if they were local. The key advantage of NFS over conventional file transfer protocols is that NFS hides the differences between local and remote files by placing them in the same name space.
object-name template Glossary object-name template. In DSM, a name that stands for more than one object. Such a name includes one or more wild-card characters, such as * and ?. See also wild-card character. Open Database Connectivity (ODBC). Microsoft’s API for connecting to a database. This interface allows programmers to write a single set of code to access different SQL databases. open system. Any computer system that adheres to the OSI standards. Open Systems Interconnection. See OSI. OSI.
Physical Layer Glossary Physical Layer. Layer 1 in the OSI Reference Model. This layer establishes the actual physical connection between the network and the computer equipment. Protocols at the physical layer include rules for the transmission of bits across the physical medium and rules for connectors and wiring. ping. (Packet Internet Groper) The name of a program used in the Internet to test reachability of destinations by sending them an ICMP echo request and waiting for a reply.
QIO Glossary QIO. A HP product that provides buffers and control blocks for protocol processes, including TLAM and NonStop IPX/SPX running on the same CPU. Remote Server Call (RSC). HP extension to Pathway that provides workstation clients with the ability to access Pathway servers. Request for Comments. See RFC. response. In DSM use, the information or confirmation supplied (as part of a response message) to an application by a subsystem in response to a DSM command. RFC.
Sequenced Packet Exchange (SPX and SPXII) Glossary Sequenced Packet Exchange (SPX and SPXII). A Novell protocol that allows two workstations or applications to communicate across the network. SPX and SPXII use Novell NetWare IPX to deliver the messages, but SPX and SPXII guarantee delivery of the messages and maintain the order of messages on the packet stream. In addition to the features of SPX, SPXII negotiates the use of larger packet sizes and employs a true windowing protocol. server.
SNAP Glossary SNAP. (Subnetwork Access Protocol). In order to run the TCP/IP protocol suite over IEEE networks, the Subnetwork Access Protocol (SNAP) defines the interface between the IP layer and the LLC layer. The interface is accomplished by the use of an extension of the LLC header that contains a predefined Service Access Point (SAP) for use in the Source SAP (SSAP) and the Destination SAP (DSAP) fields of the LLC header. socket.
subordinate names option Glossary subordinate names option. In DSM interfaces to HP data communications subsystems, the designation that the object name given in a command stands not just for itself but also for the names of objects at lower levels in a hierarchy. For NonStop IPX/SPX, the SUB option is required for the START SUBSYS, STOP SUBSYS, and ABORT SUBSYS commands. When this option is present in a command, the subordinate names are implied even though they are not given explicitly. subsystem.
Tandem Terminal Emulators (TTE) Glossary Tandem Terminal Emulators (TTE). HP software product that includes several types of terminal emulators that run on a PC with the Windows or OS/2 operating system. The HP emulator in TTE provides a 65xx connection and IXF file transfer to a NonStop system. TCP. (Transmission Control Protocol) The Internet standard transport-level protocol that provides the reliable, full-duplex stream service on which many application protocols depend.
UDP Glossary UDP. (User Datagram Protocol) The Internet standard protocol that allows an application program on one machine to send a datagram to an application program on another machine. UDP uses the Internet Protocol to deliver datagrams. Conceptually, the important difference between UDP and IP is that UDP messages include a protocol port number, allowing the sender to distinguish among multiple destinations (application programs) on the remote machine.
X25AM Glossary X25AM. (X.25 Access Method) A HP product that implements, for WANs, the services of the Network Layer and layers below. The interface that allows an application or another process to communicate with data communications hardware. $ZMGR. The process that provides the interface between the NonStop IPX/SPX subsystem and the Distributed System Management (DSM) Subsystem Control Point (SCP), which is named $ZNET. $ZNET.
Index A accept function description 5-10 use of 3-7 accept_nw function description 5-12 use of 3-8 accept_nw2 function description 5-15 use of 3-8 Address converting format of 5-30 Address family AF_NV 4-7 sockaddr_nv data structure 4-7 Advertising of services stopping 5-71/5-72 AF_NV address family 4-7 AWAITIO procedure see Guardian procedures AWAITIOX procedure see Guardian procedures B Basic program steps 3-5 Binary format converting from hexadecimal 5-29 converting to hexadecimal 5-30 bind function des
D Index CRE considerations for TAL 5-8 Creating a socket 3-5 CRE-Dependent routines 5-1 CRE-Independent routines 5-2 Functions see Socket routines see Support routines D getpeername_nw function 5-23 getsockname function 5-25 getsockname_nw function 5-25 getsockopt function 5-27 getsockopt_nw function 5-27 Guardian procedures AWAITIO 5-43 AWAITIOX description 3-1 error checking 5-5 CLOSE 3-1, 3-6 DEVICE_GETINFOBYNAME_ 3-13 FILE_CLOSE_ 3-1 FILE_GETINFOBYNAME 5-5 SETMODE 30 5-56 Data structures nv_addr 4
L Index IPX socket control limitation 5-64 IPX address converting format of 5-29 sockaddr_nv data structure 4-7 IPX address assignment 2-1 IPX address socket numbers 3-4 IPX address structure 2-1 IPX socket address nv_addr data structure 4-3 IPXPROTO Process naming 5-67 IPXPROTO process opening 5-77 ipx_addr function 5-29 ipx_ntoa function 5-30 I/O control operations 5-65 nowait and non-blocking 3-1 L Large-memory model routines 5-1/5-2 Library headers 4-1 Library routines 5-1 see also Support routines s
R Index Port number nv_addr data structure 4-3 of remote connection 5-23 socket bound to 5-25 well-known 3-4 Porting programs 3-1 Procedures AWAITIO 5-43 AWAITIOX description 3-1 error checking 5-5 CLOSE 3-1, 3-6 DEVICE_GETINFO 3-13 FILEINFO_GETINFOBYNAME_ 5-5 FILE_CLOSE_ 3-1, 3-6 SETMODE 30 5-56 Process pairs socket_backup 5-57 socket_get_info 5-59 socket_get_len 5-61 socket_get_open_info 5-62 Protocols, supported 2-5 pTAL 4-byte pointer requirement 5-7 CRE requirements 5-7 EXPORT_GLOBALS for compilation
S Index SETMODE procedure see Guardian procedures setsockopt function 5-49 setsockopt_nw function 5-49 shutdown function 5-52 use of 3-6 shutdown_nw function 5-52 sockaddr 3-4 sockaddr data structure 4-4 sockaddr_in 3-4 sockaddr_nv data structure 4-7 Socket adapted to HP environment 2-9 number 3-5 IPX address 3-4 nv_addr data structure 4-3 SPX address 3-4 Socket control limitation IPX 5-64 SPX 5-64 UDP 5-64 Socket errors see Errors socket function 5-54 Socket levels (IPX/SPX) NVPROTO_SPX 5-50 SOL_SOCKET 5
T Index Socket routines (continued) waited operations 5-4 Sockets address to which bound 5-25 binding 5-17 closing 3-6 connecting 5-20 control operations on 5-63 creating 3-5, 5-54 defined 1-4 error descriptions B-1 getting options 5-27 I/O control operations 5-65 library, defined 1-4 mapping to addresses 5-17 port to which bound 5-25 receiving data on connected TCP 5-32 receiving data on UDP or raw nowait 5-37 waited 5-35 sending data on connected TCP description 5-40 nowait 5-42 sending data on UDP or r
U Index U UDP receiving data on nowait socket 5-37 receiving data on waited socket 5-35 sending data on nowait socket 5-47 sending data on waited socket 5-45 socket control limitation 5-64 UNIX differences from Guardian environment 3-1 signals 3-3 Urgent data pending 3-3 W Waited operations in socket library 3-8 used by socket routines 5-4 Well-known IP protocol numbers A-1 Wide-data model routines 5-1/5-2 Special Characters /usr/ include directory 3-3 HP NonStop IPX/SPX Programming Manual—528022-001 I
Special Characters Index HP NonStop IPX/SPX Programming Manual—528022-001 Index -8