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

Using UNIX Domain 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:
Function result: 0 if connect is successful, –1 if failure occurs.
Example:
struct sockaddr_un peeraddr;
...
connect (s, &peeraddr, sizeof(struct sockaddr_un));
connect initiates a connection. When the connection is ready, the client
process completes its connect call and the server process can complete
its accept call.
NOTE
The client process does not get feedback that the server process has
completed the accept call. As soon as the connect call returns, the
client process can send data.
134
#include <sys/types.h>
#include <sys/un.h>
#include <sys/socket.h>
connect(s, addr, addrlen)
int s;
struct sockaddr_un *addr;
int addrlen;
Parameter
Description of Contents
s
socket descriptor of local
socket
addr
pointer to the socket
address
addrlen
length of addr
INPUT Value
socket descriptor of socket
requesting a connection
pointer to the socket
address of the socket to
which client wants to
connect
size of address structure
pointed to by addr
Chapter 6

Advertisement

Table of Contents
loading

Table of Contents