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.

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

Return Value<br />

If s is a datagram socket, every recv() call receives one datagram.<br />

The sender defines the size of the datagram. If the len parameter is<br />

less than the size of the datagram, part of the datagram is discarded.<br />

The next recv() call reads the next datagram received but not the<br />

unread part of the previous datagram. Unless ioctl() was used to<br />

mark the socket non-blocking, recv() blocks the caller until a datagram<br />

is available at the socket. If the socket has been marked nonblocking,<br />

recv() returns immediately whether or not datagrams are<br />

received.<br />

If s is a raw socket, every recv() call receives one raw datagram.<br />

The size of the raw datagram is defined by the sender. If the len parameter<br />

is less than the size of the raw datagram, part of the raw datagram<br />

is discarded. The next recv() call reads the next raw<br />

datagram received, not the unread part of the previous raw datagram.<br />

Unless ioctl() was used to mark the socket non-blocking,<br />

recv() blocks the caller until a raw datagram is available at the<br />

socket. If the socket has been marked non-blocking, recv() returns<br />

immediately whether or not raw datagrams are received. The packet<br />

contains an IP header along with the packet body, if any.<br />

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

len Specifies the size in bytes of the buffer.<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 recv() to read any out-ofband<br />

data present on the socket, rather than the<br />

regular in-band data.<br />

MSG_PEEK Specifies that you want recv() to peek at the data<br />

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

consumed, so that a subsequent receive operation<br />

sees the same data.<br />

MSG_RAWMEM Specifies that you have set buf to point to a linked<br />

list of mblks and len to the total size of the message.<br />

This system call returns either the number of bytes received or -1 if an error occurs.<br />

When the receive is shutdown by either end of the connection, a value of 0 is<br />

returned.<br />

4-46 <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!