HP Rp7410 BSD Sockets Interface Programmer's Guide - Page 40
Writing the Client Process
View all HP Rp7410 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 40 highlights
Using Internet Stream Sockets Writing the Client Process Writing the Client Process This section explains the calls your client process must make to connect with and be served by a server process. Creating a Socket The client process must call socket to create a communication endpoint. socket and its parameters are described in the following table. Include files: System call: #include #include s = socket(af, type, protocol) int af, type, protocol; Parameter Description of Contents INPUT Value af type protocol address family socket type underlying protocol to be used AF_INET SOCK_STREAM 0 (default) or value returned by getprotobyname Function result: socket number (HP-UX file descriptor), -1 if failure occurs. Example: s = socket (AF_INET, SOCK_STREAM, 0); The socket number returned is the socket descriptor for the newly created socket. This number is an HP-UX file descriptor and can be used for reading, writing or any standard file system calls after a BSD Sockets connection is established. A socket descriptor is treated like a file descriptor for an open file. When to Create Sockets The client process should create sockets before requesting a connection. Refer to the socket(2) man page for more information on socket. 40 Chapter 2