06.08.2013 Views

pSOSystem System Calls - Read

pSOSystem System Calls - Read

pSOSystem System Calls - Read

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

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

recvfrom Receives data from a socket.<br />

#include <br />

long recvfrom(<br />

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

char *buf, /* packet buffer */<br />

int len, /* packet buffer length */<br />

int flags, /* packet attributes */<br />

struct sockaddr_in *from, /* sender attributes */<br />

int *fromlen /* number of bytes recieved */<br />

)<br />

Description<br />

Arguments<br />

The recvfrom() system call is used to receive data from a socket. This system call<br />

is almost identical to recv(). The difference is recvfrom() may also return the<br />

address of the sender in the specified parameter.<br />

s Specifies the socket from which data is received. The behavior of<br />

the system call depends on the socket type. Refer to recv() for<br />

more information.<br />

buf Points to the user buffer where data is stored.<br />

len Specifies the size of the buffer in bytes.<br />

flags Specifies usage options and is the result of an OR operation performed<br />

on one or more of the following symbolic constants (defined<br />

in ). Can also be set to 0.<br />

MSG_OOB Specifies that you want recvfrom() to read<br />

any out-of-band data present on the socket,<br />

rather than the regular in-band data.<br />

MSG_PEEK Specifies that you want recvfrom() to peek at<br />

the data present on the socket; the data is returned,<br />

but not consumed, so that a subsequent<br />

receive operation sees the same data.<br />

4-48 <strong>pSO<strong>System</strong></strong> <strong>System</strong> <strong>Calls</strong>

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

Saved successfully!

Ooh no, something went wrong!