1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2<html xml:lang="en-US" lang="en-US" xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <meta http-equiv="Content-Style-Type" content="text/css" /> 6 <link rel="stylesheet" href="../../css/manpage.css" type="text/css" /> 7<title>RecvFrom</title> 8 </head> 9 <body> 10<h1><CODE><a href="../../nn/Overview.html">nn</a>::<a href="../../nn/socket/Overview.html">socket</a>::RecvFrom</CODE> Function</h1> 11<h2>Syntax</h2> 12 <div class="section"> 13 <pre class="definition"> 14s32 RecvFrom( 15 s32 s, 16 void * buf, 17 s32 len, 18 s32 flags, 19 <a href="../../nn/socket/SockAddrIn/Overview.html">SockAddrIn</a> * sockFrom 20); 21</pre> 22 </div> 23<h2>Arguments</h2> 24 <div class="section"> 25 <table class="arguments"> 26 <thead> 27 <tr> 28 <td width="15" /> 29<th>Name</th> 30<td>Description</td> 31 </tr> 32 </thead> 33 <tr> 34<td>in</td> 35<th>s</th> 36<td>Specifies a socket descriptor. Specifies a socket descriptor created using the <a href="../../nn/socket/Socket.html"><CODE>Socket</CODE></a> or <a href="../../nn/socket/Accept.html"><CODE>Accept</CODE></a> function.</td> 37 </tr> 38 <tr> 39<td>in</td> 40<th>buf</th> 41<td>Specifies a pointer to the buffer used to read out received data.</td> 42 </tr> 43 <tr> 44<td>in</td> 45<th>len</th> 46<td>Specifies the size in bytes of the buffer used to read out received data.</td> 47 </tr> 48 <tr> 49<td>in</td> 50<th>flags</th> 51<td>Specifies the message transmission type.</td> 52 </tr> 53 <tr> 54<td>out</td> 55<th>sockFrom</th> 56<td>Specifies a pointer to the socket address structure used to get the destination's address information. The <CODE>len</CODE> field of the socket address must be initialized appropriately (for example, to <CODE>sizeof(<a href="../../nn/socket/SockAddrIn/Overview.html">SockAddrIn</a>)</CODE>).</td> 57 </tr> </table> 58 </div> 59<h2>Return Values</h2> 60 <div class="section"> 61 <br /> <br /> 62 <table class="arguments"> 63 <thead> 64 <tr> 65<th>Value</th> 66<td>Description</td> 67 </tr> 68 </thead> 69 <tr> 70 <th>0</th> 71<td>For stream sockets (<CODE>SOCK_STREAM</CODE>), this indicates that the socket cannot accept any more messages because the remote host has finished sending messages. For datagram sockets (<CODE>SOCK_DGRAM</CODE>), this function does not return <CODE>0</CODE>.</td> 72 </tr> 73 <tr> 74 <th>1</th> 75<td>or more: The size (in bytes) of data read.</td> 76 </tr> 77 <tr> 78<th><CODE>EAGAIN</CODE></th> 79<td>No data has been received (in the case of non-blocking mode). Already tried to receive data in blocking mode, but it was blocked (in the case of blocking mode).</td> 80 </tr> 81 <tr> 82<th><CODE>EBADF</CODE></th> 83<td>The socket descriptor is invalid.</td> 84 </tr> 85 <tr> 86<th><CODE>ECONNRESET</CODE></th> 87<td>If the socket is a stream socket (<CODE>SOCK_STREAM</CODE>), the connection has been reset for a reason similar to the following. Communication reset by a connected remote host. The connection was canceled for some reason such as an <CODE>SOCleanup</CODE> function call or detection of a network interface disconnection. A fatal ICMP notification (such as a Destination Unreachable message) was received while the running process was maintaining the connection. When using a datagram socket (<CODE>SOCK_DGRAM</CODE>), an ICMP notification for controlling subsequent communications (a source control message) was received from the destination or a router on the route.</td> 88 </tr> 89 <tr> 90<th><CODE>EINVAL</CODE></th> 91<td>Indicates an illegal call of one of the following. The socket address specified in <SPAN class="argument">sockFrom</SPAN> is invalid. The pointer specified by <SPAN class="argument">buf</SPAN> is invalid. The size specified by <SPAN class="argument">len</SPAN> is invalid. This error also results in cases where the call itself may not have been illegal, but an ICMP notification was received indicating the library sent an illegal packet over the network via a datagram socket (<CODE>SOCK_DGRAM</CODE>).</td> 92 </tr> 93 <tr> 94<th><CODE>EINTR</CODE></th> 95<td>Suspended.</td> 96 </tr> 97 <tr> 98<th><CODE>ENETDOWN</CODE></th> 99<td>The network is not available.</td> 100 </tr> 101 <tr> 102<th><CODE>ENETRESET</CODE></th> 103<td>Socket library is not initialized.</td> 104 </tr> 105 <tr> 106<th><CODE>ENOMEM</CODE></th> 107<td>Cannot allocate the memory required for the process.</td> 108 </tr> 109 <tr> 110<th><CODE>ENOTCONN</CODE></th> 111<td>If the specified socket is closed or is a stream socket (<CODE>SOCK_STREAM</CODE>), it cannot be used for the process because communications have not been established. If the socket is a datagram socket (<CODE>SOCK_DGRAM</CODE>), receiving may have been canceled for some reason such as the source's socket address not being appropriately allocated by <a href="../../nn/socket/Bind.html"><CODE>Bind</CODE></a> or detection of a network interface disconnection. 。</td> 112 </tr> 113 <tr> 114<th><CODE>EOPNOTSUPP</CODE></th> 115<td>An unsupported flag was specified in <SPAN class="argument">flags</SPAN>.</td> 116 </tr> 117 <tr> 118<th><CODE>ETIMEDOUT</CODE></th> 119<td>If the socket is a stream socket (<CODE>SOCK_STREAM</CODE>), receiving was canceled because the connection timed out. If the socket is a datagram socket (<CODE>SOCK_DGRAM</CODE>), an ICMP message was received indicating that previously sent data timed out and did not arrive at the destination.</td> 120 </tr> 121 <tr> 122<th><CODE>EWOULDBLOCK</CODE></th> 123<td>Same as <CODE>EAGAIN</CODE>.</td> 124 </tr> 125 </table> </div> 126<h2>Description</h2> 127 <div class="section"> 128<p>Attempts to receive data (messages) from a remote host via a socket.</p><p>This function usually blocks until the socket receives a message. However, if the <a href="../../nn/socket/Fcntl.html"><CODE>Fcntl</CODE></a> function has set the socket to non-blocking mode and <SPAN class="argument">flags</SPAN> is set to <CODE>MSG_DONTWAIT</CODE>, this function does not block and only gets the data already received at the time this function is called. <br />For datagram sockets (<CODE>SOCK_DGRAM</CODE>), the entire message is read out in a single operation. If the message cannot fit into the allocated buffer and <CODE>MSG_PEEK</CODE> is not set in <SPAN class="argument">flags</SPAN>, any data that does not fit into the buffer is discarded.<br /> For stream sockets (<CODE>SOCK_STREAM</CODE>), message boundaries are ignored. In this case, data is returned to the user as it becomes usable.</p><!-- write here --></div> 129<h2>See Also</h2> 130 <div class="section"> 131 <p class="reference"> 132 <br /> </p> 133 </div> 134<h2>Revision History</h2> 135 <div class="section"> 136 <dl class="history"> 137 <dt>2010/06/14</dt> 138<dd>Initial version.<br /> 139 </dd> 140 </dl> 141 </div> 142 <hr><p>CONFIDENTIAL</p></body> 143</html> 144