CONTENTS Title Page Copyright Page Preface 1 UCX Programming Interfaces 1.1 OpenVMS System Services 1.2 DEC C Socket Interface 1.3 Location of Application Development Files 2 Communication Process and Calling Sequence 2.1 Byte Order of Internet Messages 2.2 TCP Socket Communication Process 2.3 UDP Socket Communication Process 2.4 TCP Server Calling Sequence 2.5 UCP Server Calling Sequence 2.6 TCP Client Calling Sequence 2.7 UDP Client Calling Sequence 3 Writing Internet Applications 3.1 Location of Example Programs 3.2 Compiling With the DEC C Language 3.3 Linking Programs Compiled by DEC C 3.4 Linking Programs Compiled by VAX C 3.5 Creating a Device Socket 3.5.1 Creating Device Sockets with OpenVMS System Services 3.5.2 Creating Device Sockets with the C Socket Interface 3.6 Using the Berkeley Internet Name Domain Service 3.6.1 Doing a BIND Lookup with OpenVMS System Service 3.6.2 Doing a BIND Lookup with the C Socket Interface 3.7 Binding a Socket 3.7.1 Binding Sockets with OpenVMS System Service 3.7.2 Binding Sockets with the C Socket Interface 3.8 Making a Socket a Listener (TCP Server) 3.8.1 Listening to a Socket with OpenVMS System Services 3.8.2 Listening to a Socket with a C Socket Interface 3.9 Initiating a Connection with a TCP Client 3.9.1 Initiating a Connection with OpenVMS System Services 3.9.2 Initiating a Connection with a C Socket Interface 3.10 Accepting a Connection with a TCP Server 3.10.1 Accepting a Connection Using OpenVMS System Services 3.10.2 Accepting a Connection Using a C Socket Interface 3.11 Obtaining Device Socket Information 3.11.1 Getting Device Socket Information with OpenVMS System Services 3.11.2 Getting Device Socket Information with a C Socket Interface 3.12 Reading Data 3.12.1 Reading Data with OpenVMS System Services 3.12.2 Reading Data with a C Socket Interface 3.13 Reading Out-of-Band Data (TCP) 3.13.1 Reading OOB Data with OpenVMS System Services 3.13.2 Reading OOB Data with a C Socket Interface 3.14 Peeking at Queued Messages 3.14.1 Peeking at Data with OpenVMS System Services 3.14.2 Peeking at Data with a C Socket Interface 3.15 Writing Data 3.15.1 Writing Data with OpenVMS System Service 3.15.2 Writing Data with a C Socket Interface 3.16 Sending OOB Data (TCP) 3.16.1 Writing OOB Data with OpenVMS System Services 3.16.2 Writing OOB Data with a C Socket Interface 3.17 Writing Data and Broadcast Messages (UDP) 3.18 Sending a Datagram (UDP) 3.18.1 Sending Datagrams with OpenVMS System Services 3.18.2 Broadcasting Datagrams with OpenVMS System Services 3.18.3 Broadcasting Datagrams with a C Socket Interface 3.19 Closing and Deleting a Socket 3.19.1 Closing and Deleting with OpenVMS System Service 3.19.2 Closing and Deleting with a C Socket Interface 3.20 Shutting Down Sockets 3.20.1 Shutting Down a Socket with OpenVMS System Services 3.20.2 Shutting Down with a C Socket Interface 3.21 Canceling I/O Operations 4 Using the OpenVMS System Services 4.1 $QIO System Service Variations 4.2 $QIO Syntax 4.2.1 $QIO Function-Dependent Parameters 4.3 Common $QIO Functions 4.4 $QIO Arguments 4.4.1 Function-Independent $QIO Arguments 4.4.2 Function-Dependent $QIO Arguments 4.5 UCX Item Lists and UCX Item List Descriptors 4.6 Specifying an Input Parameter List 4.7 Specifying an Output Parameter List 4.8 Specifying the Socket Name 4.9 Specifying the Socket Options, Protocol Options, and I/O Control (IOCTL) Parameters 5 OpenVMS System Services Reference $ASSIGN $CANCEL $DASSGN $GETDVI $QIO 5.1 Internet I/O Function Codes IO$_ACCESS IO$_ACPCONTROL IO$_DEACCESS IO$_READVBLK IO$_SENSEMODE/IO$_SENSECHAR IO$_SETMODE/IO$_SETCHAR IO$_SETMODE | IO$M_OUTBAND IO$_SETMODE | IO$M_READATTN IO$_SETMODE | IO$M_WRTATTN IO$_WRITEVBLK 6 Using DEC C Socket Routines 6.1 Internet Protocols 6.1.1 TCP Sockets 6.1.1.1 Wildcard Addressing 6.1.2 UDP Sockets 6.2 Calling a C Socket Routine from an AST State 6.3 Calling From KERNEL or EXEC Modes 6.4 Standard I/O 6.5 Event Flags 6.6 Suppressing DEC C Compilation Warnings 6.7 Header Files 6.8 DEC C Structures 6.8.1 hostent Structure 6.8.2 in_addr Structure 6.8.3 iovec Structure 6.8.4 linger Structure 6.8.5 msghdr Structure 6.8.6 netent Structure 6.8.7 sockaddr Structure 6.8.8 sockaddr_in Structure 6.8.9 timeval Structure 6.9 errno Values 7 DEC C Socket Routine Reference accept( ) bind( ) close( ) connect( ) listen( ) read( ) recv( ) recvfrom( ) recvmsg( ) select( ) send( ) sendmsg( ) sendto( ) shutdown( ) socket( ) write( ) gethostbyaddr( ) gethostbyname( ) gethostname( ) getnetbyaddr( ) getnetbyname( ) getnetent( ) getpeername( ) getprotobyname( ) getprotobynumber( ) getprotoent( ) getservbyname( ) getservbyport( ) getsockname( ) getsockopt( ) htonl( ) htons( ) inet_addr( ) inet_lnaof( ) inet_makeaddr( ) inet_netof( ) inet_network( ) inet_ntoa( ) ntohl( ) ntohs( ) setsockopt( ) vaxc$get_sdc( ) 8 Error Codes A Online Program Examples A.1 TCP/IP Client Using MACRO-32 and QIO Calls Example A.2 TCP/IP Server Using QIO Calls Example A.3 UDP/IP Client Write Operation - MACRO-32 Example A.4 UDP/IP Server - C Socket Example A.5 TCP/IP Server - C Socket Example A.6 TCP/IP Server Accepting a Connection from the Auxiliary Server Example EXAMPLES 3-1 OpenVMS System Service - Device Socket Example 3-2 Binding a Socket with C Socket Programming Example 3-3 OpenVMS System Service BIND Lookup Example 3-4 C Socket BIND Example 3-5 Binding Socket with OpenVMS System Service Example 3-6 C Socket Binding Socket Example 3-7 OpenVMS System Service Listen Code Example 3-8 C Socket Listen Code Example 3-9 OpenVMS System Service Connection Request Example 3-10 C Socket Connection Request Example 3-11 OpenVMS System Service Connection Accept Example 3-12 C Socket Connection Accept Example 3-13 OpenVMS System Service Device Socket Information Example 3-14 C Socket Device Socket Information Example 3-15 OpenVMS System Service Read Example 3-16 C Socket Read Example 3-17 IO$M_INTERRUPT Out-of-Band Data Example 3-18 C Socket Out-of-Band Data Example 3-19 C Socket Peek Example 3-20 OpenVMS System Service Write Example 3-21 C Socket Write Example 3-22 C Socket Writing Out-of-Band Data Example 3-23 OpenVMS System Service Close and Delete Example 3-24 C Socket Delete Socket Example 3-25 OpenVMS System Service Shutdown Example 3-26 C Socket Shutdown Example 4-1 Specifying IOCTL Parameters 5-1 $ASSIGN Service - MACRO-32 Programming Example 5-2 $ASSIGN System Service C Programming Example 5-3 $CANCEL System Service MACRO-32 Programming Example 5-4 $CANCEL System Service C Programming Example 5-5 $DASSGN System Service MACRO-32 Programming Example 5-6 $DASSGN System Service C Programming Example 5-7 IO$_ACPCONTROL MACRO-32 Programming Example 5-8 IO$_ACPCONTROL System Service C Programming Example 5-9 IO$_READVBLK Function MACRO-32 Programming Example 5-10 IO$_READVBLK Function C Programming Example 5-11 IO$_READVBLK Function C Programming Example 5-12 IO$_WRITEVBLK Function MACRO-32 Programming Example 5-13 IO$_WRITEVBLK Function (Vectored) C Programming Example 5-14 IO$_WRITEVBLK Function C Programming Example A-1 TCP/IP Client using MACRO-32 and QIO Calls A-2 TCP/IP Server using QIO Calls A-3 UDP/IP Client Write Operation Using MACRO-32 and QIO Calls A-4 UDP/IP Server using the C Socket Interface A-5 TCP/IP Server Using the C Socket Interface A-6 TCP/IP Server Accepting a Connection from the Auxiliary Server FIGURES 2-1 TCP Socket Communication Process 2-2 UDP Socket Communication Process 4-1 I/O Status Block 4-2 Specifying an Input Parameter List 4-3 Specifying an Output Parameter List 4-4 Specifying the Local or Remote Socket Name 4-5 Specifying Socket Options 4-6 Specifying IOCTL Functions 4-7 Getting Socket Options 4-8 Getting IOCTL Parameters 5-1 Single Item Descriptor TABLES 1-1 Internet Definition Files - SYS$LIBRARY: 1-2 C Socket Routine Libraries - SYS$LIBRARY: 1-3 UDP/IP Protocol Programming Examples - UCX$EXAMPLES: 1-4 TCP/IP Protocol Programming Examples - UCX$EXAMPLES: 2-1 Server Calling Sequence - TCP 2-2 Server Calling Sequence - UDP 2-3 Client Calling Sequence - TCP 2-4 Client Calling Sequence - UDP 3-1 Reference Information 4-1 $QIO Arguments 4-2 Internet Symbol Definition Files 4-3 $QIO Functions 4-4 Device- and Function-Independent Arguments 4-5 I/O Status Block Fields 4-6 Function-Dependent $QIO Arguments 4-7 p5 Descriptor Fields 4-8 p6 Descriptor Fields 4-9 sockaddr_in Fields 5-1 OpenVMS System Service and Equivalent C Socket Call 5-2 Symbolic Names for $GETDVI 5-3 Device Unit Status Symbolic Names 5-4 Internet I/O Function Codes 5-5 Valid INET Subfunction Codes 5-6 INET Call Codes 5-7 Valid Flags for the p4 Argument 5-8 The p6 Socket Options 5-9 TCP/IP Options 5-10 IP Options 5-11 IOCTL Commands 5-12 Valid Protocols for IO$_SETMODE and IO$_SETCHAR 5-13 Valid Socket Types for IO$_SETMODE and IO$_SETCHAR 5-14 Communications Socket Options 5-15 TCP Options 5-16 IP Options 5-17 Valid WRITE Flags for the p4 Argument 6-1 errno Values 7-1 Basic Communication Routines 7-2 Communication Support Routines 7-3 Communications Socket Options 7-4 TCP/IP Options 7-5 IP Options 8-1 Translation of Socket Error Codes to OpenVMS Error Codes A-1 Location of Online Program Examples - UCX$EXAMPLES: