06.08.2013 Views

pSOSystem System Calls - Read

pSOSystem System Calls - Read

pSOSystem System Calls - Read

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

pNA+ <strong>System</strong> <strong>Calls</strong> connect<br />

connect Initiates a connection on a socket.<br />

#include <br />

long connect(<br />

int s, /* socket descriptor */<br />

struct sockaddr_in *addr, /* socket attributes */<br />

int addrlen /* attribute size */<br />

)<br />

Description<br />

Arguments<br />

This system call is used to establish an association between a local socket and a<br />

foreign socket.<br />

Generally, a stream socket connects only once. A datagram socket can use<br />

connect() multiple times to change its association. A datagram socket can<br />

dissolve the association by connecting to an invalid address, such as the null<br />

address INADDR_ANY defined in pna.h.<br />

If a stream socket is specified, connect() initiates a connection request to the<br />

foreign socket. The caller is blocked until a connection is established, unless the<br />

socket is non-blocking.<br />

If a datagram socket is specified, connect() associates the socket with the socket<br />

address supplied. This address is used by future send() calls to determine the<br />

datagram's destination. This is the only address from which datagrams can be<br />

received.<br />

If a raw socket is specified, connect() associates the socket with the socket<br />

address supplied. This address is used by future send() calls to determine the<br />

datagram's destination. This is the only address from which datagrams can be<br />

received.<br />

s Specifies the local socket.<br />

<strong>pSO<strong>System</strong></strong> <strong>System</strong> <strong>Calls</strong> 4-9<br />

4

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!