VSI TCP/IP Services for Openvms Sockets API and System Services Programming
Total Page:16
File Type:pdf, Size:1020Kb
VSI TCP/IP Services for OpenVMS Sockets API and System Services Programming Document Number: DO-TCPAPI-01A Publication Date: November 2020 Revision Update Information: This is a new manual. Operating System and Version: VSI OpenVMS Integrity servers Version 8.4-2L1 VSI OpenVMS Alpha Version 8.4-2L1 Software Version: VSI TCP/IP Services Version 5.7 VMS Software, Inc. (VSI) Burlington, Massachusetts, USA VSI TCP/IP Services for OpenVMS Sockets API and System Services Programming Copyright © 2021 VMS Software, Inc. (VSI), Burlington, Massachusetts, USA Legal Notice Confidential computer software. Valid license from VSI 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. The only warranties for VSI products and services are set forth in the express warranty statements accompanying such products and services. Nothing herein should be construed as constituting an additional warranty. VSI shall not be liable for technical or editorial errors or omissions contained herein. HPE, HPE Integrity, HPE Alpha, and HPE Proliant are trademarks or registered trademarks of Hewlett Packard Enterprise. Intel, Itanium and IA-64 are trademarks or registered trademarks of Intel Corporation or its subsidiaries in the United States and other countries. The VSI OpenVMS documentation set is available on DVD. ii VSI TCP/IP Services for OpenVMS Sockets API and System Services Programming Preface ................................................................................................................................... vii 1. About VSI .................................................................................................................... vii 2. Intended Audience ........................................................................................................ vii 3. Document Structure ...................................................................................................... vii 4. Related Documentation ................................................................................................ viii 5. VSI Encourages Your Comments .................................................................................... ix 6. How to Order Additional Documentation ........................................................................ ix 7. Typographical Conventions ............................................................................................ ix Chapter 1. Application Programming Interfaces ............................................................... 1 1.1. BSD Sockets ................................................................................................................ 1 1.2. OpenVMS System Services .......................................................................................... 1 1.3. Application Development Files ..................................................................................... 2 1.3.1. Definition Files ................................................................................................. 2 1.3.2. Libraries ........................................................................................................... 4 1.3.3. Programming Examples ..................................................................................... 4 1.4. Compiling and Linking C Language Programs ............................................................... 4 1.4.1. Compiling and Linking Programs Using BSD Version 4.4 ................................... 5 1.4.2. C Compilation Warnings .................................................................................... 5 1.5. Using 64-Bit Addresses (Alpha and I64 Only) ............................................................... 5 Chapter 2. Writing Network Applications .......................................................................... 7 2.1. The Client/Server Communication Process .................................................................... 7 2.1.1. Using the TCP Protocol ..................................................................................... 7 2.1.2. Using the UDP Protocol .................................................................................. 10 2.2. Creating a Socket ....................................................................................................... 12 2.2.1. Creating Sockets (Sockets API) ........................................................................ 12 2.2.2. Creating Sockets (System Services) .................................................................. 13 2.3. Binding a Socket (Optional for Clients) ....................................................................... 15 2.3.1. Binding a Socket (Sockets API) ....................................................................... 16 2.3.2. Binding a Socket (System Services) ................................................................. 17 2.4. Making a Socket a Listener (TCP Protocol) ................................................................. 20 2.4.1. Setting a Socket to Listen (Sockets API) ........................................................... 20 2.4.2. Setting a Socket to Listen (System Services) ..................................................... 21 2.5. Initiating a Connection (TCP Protocol) ........................................................................ 25 2.5.1. Initiating a Connection (Sockets API) ............................................................... 25 2.5.2. Initiating a Connection (System Services) ......................................................... 26 2.6. Accepting a Connection (TCP Protocol) ...................................................................... 30 2.6.1. Accepting a Connection (Sockets API) ............................................................. 30 2.6.2. Accepting a Connection (System Services) ....................................................... 32 2.7. Getting Socket Options ............................................................................................... 37 2.7.1. Getting Socket Information (Sockets API) ........................................................ 37 2.7.2. Getting Socket Information (System Services) ................................................... 39 2.8. Setting Socket Options ............................................................................................... 44 2.8.1. Setting Socket Options (Sockets API) ............................................................... 45 2.8.2. Setting Socket Options (System Services) ......................................................... 47 2.9. Reading Data ............................................................................................................. 53 2.9.1. Reading Data (Sockets API) ............................................................................. 53 2.9.2. Reading Data (System Services) ....................................................................... 55 2.10. Receiving IP Multicast Datagrams ............................................................................. 59 2.11. Reading Out-of-Band Data (TCP Protocol) ................................................................ 60 2.11.1. Reading OOB Data (Sockets API) .................................................................. 61 2.11.2. Reading OOB Data (System Services) ............................................................ 61 iii VSI TCP/IP Services for OpenVMS Sockets API and System Services Programming 2.12. Peeking at Queued Messages .................................................................................... 62 2.12.1. Peeking at Data (Sockets API) ....................................................................... 62 2.12.2. Peeking at Data (System Services) .................................................................. 66 2.13. Writing Data ............................................................................................................ 66 2.13.1. Writing Data (Sockets API) ............................................................................ 66 2.13.2. Writing Data (System Services) ...................................................................... 68 2.14. Writing OOB Data (TCP Protocol) ............................................................................ 75 2.14.1. Writing OOB Data (Sockets API) ................................................................... 75 2.14.2. Writing OOB Data (System Services) ............................................................. 76 2.15. Sending Datagrams (UDP Protocol) .......................................................................... 77 2.15.1. Sending Datagrams (System Services) ............................................................ 77 2.15.2. Sending Broadcast Datagrams (Sockets API) ................................................... 77 2.15.3. Sending Broadcast Datagrams (System Services) ............................................. 77 2.15.4. Sending Multicast Datagrams ......................................................................... 77 2.16. Using the Berkeley Internet Name Domain Service .................................................... 79 2.16.1. BIND Lookups (Sockets API) ........................................................................ 79 2.16.2. BIND Lookups (System Services) .................................................................