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>nn::socket::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 communication target'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>A return value of one or more indicates the number of bytes of received messages.</td>
76        </tr>
77        <tr>
78<th><CODE>ENETRESET</CODE></th>
79<td>Socket library is not initialized.</td>
80        </tr>
81        <tr>
82<th><CODE>EBADF</CODE></th>
83<td>Invalid socket descriptor.</td>
84        </tr>
85        <tr>
86<th><CODE>EAGAIN</CODE></th>
87<td>There is no data or out-of-band data waiting to be received, even when <CODE>O_NONBLOCK</CODE> is set in the socket descriptor (or when the <CODE>MSG_DONTWAIT</CODE> flag is set).</td>
88        </tr>
89        <tr>
90<th><CODE>EINVAL</CODE></th>
91<td>Invalid processing.</td>
92        </tr>
93        <tr>
94<th><CODE>EOPNOTSUPP</CODE></th>
95<td>Process not supported.</td>
96        </tr>
97        <tr>
98<th><CODE>ENOTCONN</CODE></th>
99<td>Not connected.</td>
100        </tr>
101        <tr>
102<th><CODE>ECONNRESET</CODE></th>
103<td>The connection was reset.</td>
104        </tr>
105        <tr>
106<th><CODE>EINTR</CODE></th>
107<td>Suspended.</td>
108        </tr>
109        <tr>
110<th><CODE>ETIMEDOUT</CODE></th>
111<td>Timeout.</td>
112        </tr>
113        <tr>
114<th><CODE>ENETDOWN</CODE></th>
115<td>The local network interface is down.</td>
116        </tr>
117      </table> </div>
118<h2>Description</h2>
119    <div class="section">
120<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. 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 <SPAN class="argument">flags</SPAN> is not set to <CODE>MSG_PEEK</CODE>, any data that does not fit into the buffer is discarded. 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>
121<h2>See Also</h2>
122    <div class="section">
123      <p class="reference">
124            <br /> </p>
125    </div>
126<h2>Revision History</h2>
127    <div class="section">
128      <dl class="history">
129        <dt>2010/06/14</dt>
130<dd>Initial version.<br />
131        </dd>
132      </dl>
133    </div>
134  <hr><p>CONFIDENTIAL</p></body>
135</html>