Requesting A Connection - HP Rp3440-4 - 9000 - 0 MB RAM Programmer's Manual

Bsd sockets interface programmer’s guide
Hide thumbs Also See for Rp3440-4 - 9000 - 0 MB RAM:
Table of Contents

Advertisement

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:
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
System call:
connect(s, addr, addrlen)
int s;
struct sockaddr *addr;
int addrlen;
Parameter
s
socket descriptor of local
socket
addr
pointer to the socket
address
addrlen
length of address
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
Description of
Contents
Using Internet Stream Sockets
Writing the Client Process
INPUT Value
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
41

Advertisement

Table of Contents
loading

Table of Contents