HP Rp5405 BSD Sockets Interface Programmer's Guide - Page 41
Requesting a Connection
View all HP Rp5405 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 41 highlights
Using Internet Stream Sockets Writing the Client Process Requesting a Connection Once the server process is listening for connection requests, the client process can request a connection with the connect call. connect and its parameters are described in the following table. Include files: System call: #include #include #include connect(s, addr, addrlen) int s; struct sockaddr *addr; int addrlen; Parameter Description of Contents INPUT Value s addr addrlen socket descriptor of local socket pointer to the socket address length of address socket descriptor of socket requesting connection pointer to the socket address of the socket to which client wants to connect size of address structure pointed to by addr Function result: 0 if connect is successful, -1 if failure occurs. Example: struct sockaddr_in peeraddr; ... connect (s, &peeraddr, sizeof(struct sockaddr_in)); connect initiates a connection and blocks if the connection is not ready, unless you are using nonblocking I/O. When the connection is ready, the client process completes its connect call and the server process can complete its accept call. Chapter 2 41