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>SendTo</title>
8  </head>
9  <body>
10<h1><CODE><a href="../../nn/Overview.html">nn</a>::<a href="../../nn/socket/Overview.html">socket</a>::SendTo</CODE> Function</h1>
11<h2>Syntax</h2>
12    <div class="section">
13      <pre class="definition">
14s32 SendTo(
15     s32 s,
16     const void * buf,
17     s32 len,
18     s32 flags,
19     const <a href="../../nn/socket/SockAddrIn/Overview.html">SockAddrIn</a> * sockTo
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 that is used to maintain send data.</td>
42        </tr>
43        <tr>
44<td>in</td>
45<th>len</th>
46<td>Specifies the size of data to be sent in bytes.</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>in</td>
55<th>sockTo</th>
56<td>Specifies a pointer to the socket address structure that maintains address information about the destination.<br />This argument is valid only for datagram sockets (<CODE>SOCK_DGRAM</CODE>), but is ignored if the destination's socket address is specified by the <a href="../../nn/socket/Connect.html"><CODE>Connect</CODE></a> function.</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><CODE>0</CODE> or higher</th>
71<td>Represents the size of data (in bytes) that has been sent or that is reserved for sending. In non-blocking mode, this is sometimes smaller than the size of data requested.</td>
72        </tr>
73        <tr>
74<th><CODE>EAGAIN</CODE></th>
75<td>In blocking mode, indicates that an attempt to send data has already been made and that it is blocked. If the socket is a non-blocking mode stream socket (<CODE>SOCK_STREAM</CODE>), data to be sent out-of-band cannot be reserved for sending in the internal send buffer.</td>
76        </tr>
77        <tr>
78<th><CODE>EBADF</CODE></th>
79<td>The socket descriptor is invalid.</td>
80        </tr>
81        <tr>
82<th><CODE>ECONNRESET</CODE></th>
83<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 cancelled due to disconnection from the access point or some similar cause. 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>
84        </tr>
85        <tr>
86<th><CODE>EINTR</CODE></th>
87<td>Suspended.</td>
88        </tr>
89        <tr>
90<th><CODE>EINVAL</CODE></th>
91<td>Invalid call.</td>
92        </tr>
93        <tr>
94<th><CODE>EOPNOTSUPP</CODE></th>
95<td>An unsupported flag was specified in <SPAN class="argument">flags</SPAN>.</td>
96        </tr>
97        <tr>
98<th><CODE>EDESTADDRREQ</CODE></th>
99<td>If the socket is a stream socket (<CODE>SOCK_STREAM</CODE>), the socket is being used to accept connection requests using the <a href="../../nn/socket/Listen.html"><CODE>Listen</CODE></a> function. If the socket is a datagram socket (<CODE>SOCK_DGRAM</CODE>), the socket address of the destination to which data is to be sent is not determined.</td>
100        </tr>
101        <tr>
102<th><CODE>EMSGSIZE</CODE></th>
103<td>If the socket is a datagram socket (<CODE>SOCK_DGRAM</CODE>), the size of data to be sent exceeds the size of the internal send buffer.</td>
104        </tr>
105        <tr>
106<th><CODE>ENETDOWN</CODE></th>
107<td>The network is not available.</td>
108        </tr>
109        <tr>
110<th><CODE>ENETRESET</CODE></th>
111<td>Socket library is not initialized.</td>
112        </tr>
113        <tr>
114<th><CODE>ENETUNREACH</CODE></th>
115<td>If the socket is a datagram socket (<CODE>SOCK_DGRAM</CODE>), an ICMP notification (Destination Unreachable message) was received indicating that the attempted send destination cannot be found or that data previously sent did not arrive at the destination.</td>
116        </tr>
117        <tr>
118<th><CODE>ENOBUFS</CODE></th>
119<td>This error indicates that either a socket address cannot be temporarily assigned to a datagram socket (<CODE>SOCK_DGRAM</CODE>) for which a source socket address has not been assigned, or that a temporary send buffer (required when sending and receiving data using a single socket) cannot be allocated.</td>
120        </tr>
121        <tr>
122<th><CODE>ENOMEM</CODE></th>
123<td>Cannot allocate the memory required for the process.</td>
124        </tr>
125        <tr>
126<th><CODE>ENOTCONN</CODE></th>
127<td>Not connected.</td>
128        </tr>
129        <tr>
130<th><CODE>ETIMEDOUT</CODE></th>
131<td>If the socket is a stream socket (<CODE>SOCK_STREAM</CODE>), sending was cancelled because the connection timed out. If the socket is a datagram socket (<CODE>SOCK_DGRAM</CODE>), an ICMP notification (Destination Unreachable message) was received that indicated previously sent data timed out and did not reach the destination.</td>
132        </tr>
133        <tr>
134<th><CODE>EWOULDBLOCK</CODE></th>
135<td>Same as <CODE>EAGAIN</CODE>.</td>
136        </tr>
137      </table> </div>
138<h2>Description</h2>
139    <div class="section">
140<p>Attempts to send data (messages) to a remote host via a socket.</p><p>This function normally blocks until there is enough free space in the socket's send buffer to store the messages, unless non-blocking mode has been set by the <a href="../../nn/socket/Fcntl.html"><CODE>Fcntl</CODE></a> function or <CODE>MSG_DONTWAIT</CODE> is set in <SPAN class="argument">flags</SPAN>. In those cases this function does not block.<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 <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>
141<h2>See Also</h2>
142    <div class="section">
143<p class="reference"><CODE><a href="../../nn/socket/Send.html">Send</a><BR> <a href="../../nn/socket/Write.html">Write</a><br /></CODE> </p>
144    </div>
145<h2>Revision History</h2>
146    <div class="section">
147      <dl class="history">
148        <dt>2010/06/14</dt>
149<dd>Initial version.<br />
150        </dd>
151      </dl>
152    </div>
153  <hr><p>CONFIDENTIAL</p></body>
154</html>
155