1502 Remove conversion cruft from manpages
[unleashed.git] / usr / src / man / man3xnet / sendto.3xnet
blob9c9e75bc5791438029f8cc8dfe9718f5c7fd5b8c
1 '\" te
2 .\" Copyright (c) 1992, X/Open Company Limited.  All Rights Reserved.  Portions Copyright (c) 2003, Sun Microsystems, Inc.  All Rights Reserved.
3 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
4 .\" http://www.opengroup.org/bookstore/.
5 .\" The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
6 .\"  This notice shall appear on any product containing this material.
7 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
8 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
9 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
10 .TH SENDTO 3XNET "Nov 1, 2003"
11 .SH NAME
12 sendto \- send a message on a socket
13 .SH SYNOPSIS
14 .LP
15 .nf
16 \fBcc\fR [ \fIflag\fR... ] \fIfile\fR... \fB-lxnet\fR [ \fIlibrary\fR ... ]
17 #include <sys/socket.h>
19 \fBssize_t\fR \fBsendto\fR(\fBint\fR \fIsocket\fR, \fBconst void *\fR\fImessage\fR, \fBsize_t\fR \fIlength\fR, \fBint\fR \fIflags\fR,
20      \fBconst struct sockaddr *\fR\fIdest_addr\fR, \fBsocklen_t\fR \fIdest_len\fR);
21 .fi
23 .SH DESCRIPTION
24 .sp
25 .LP
26 The \fBsendto()\fR function sends a message through a connection-mode or
27 connectionless-mode socket.  If the socket is connectionless-mode, the message
28 will be sent to the address specified by \fIdest_addr\fR.  If the socket is
29 connection-mode, \fIdest_addr\fR is ignored.
30 .sp
31 .LP
32 If the socket protocol supports broadcast and the specified address is a
33 broadcast address for the socket protocol, \fBsendto()\fR will fail if the
34 \fBSO_BROADCAST\fR option is not set for the socket.
35 .sp
36 .LP
37 The \fIdest_addr\fR argument specifies the address of the target. The
38 \fIlength\fR argument specifies the length of the message.
39 .sp
40 .LP
41 Successful completion of a call to \fBsendto()\fR does not guarantee delivery
42 of the message. A return value of \fB\(mi1\fR indicates only locally-detected
43 errors.
44 .sp
45 .LP
46 If space is not available at the sending socket to hold the message to be
47 transmitted and the socket file descriptor does not have \fBO_NONBLOCK\fR set,
48 \fBsendto()\fR blocks until space is available. If space is not available at
49 the sending socket to hold the message to be transmitted and the socket file
50 descriptor does have \fBO_NONBLOCK\fR set, \fBsendto()\fR will fail.
51 .sp
52 .LP
53 The socket in use may require the process to have appropriate privileges to use
54 the \fBsendto()\fR function.
55 .SH PARAMETERS
56 .sp
57 .LP
58 The function takes the following arguments:
59 .sp
60 .ne 2
61 .na
62 \fB\fIsocket\fR\fR
63 .ad
64 .RS 13n
65 Specifies the socket file descriptor.
66 .RE
68 .sp
69 .ne 2
70 .na
71 \fB\fImessage\fR\fR
72 .ad
73 .RS 13n
74 Points to a buffer containing the message to be sent.
75 .RE
77 .sp
78 .ne 2
79 .na
80 \fB\fIlength\fR\fR
81 .ad
82 .RS 13n
83 Specifies the size of the message in bytes.
84 .RE
86 .sp
87 .ne 2
88 .na
89 \fB\fIflags\fR\fR
90 .ad
91 .RS 13n
92 Specifies the type of message transmission. Values of this argument are formed
93 by logically OR'ing zero or more of the following flags:
94 .sp
95 .ne 2
96 .na
97 \fBMSG_EOR\fR
98 .ad
99 .RS 11n
100 Terminates a record (if supported by the protocol)
104 .ne 2
106 \fBMSG_OOB\fR
108 .RS 11n
109 Sends out-of-band data on sockets that support out-of-band data. The
110 significance and semantics of out-of-band data are protocol-specific.
116 .ne 2
118 \fB\fIdest_addr\fR\fR
120 .RS 13n
121 Points to a \fBsockaddr\fR structure containing the destination address.  The
122 length and format of the address depend on the address family of the socket.
126 .ne 2
128 \fB\fIdest_len\fR\fR
130 .RS 13n
131 Specifies the length of the \fBsockaddr\fR structure pointed to by the
132 \fIdest_addr\fR argument.
135 .SH USAGE
138 The \fBselect\fR(3C) and \fBpoll\fR(2) functions can be used to determine when
139 it is possible to send more data.
140 .SH RETURN VALUES
143 Upon successful completion, \fBsendto()\fR returns the number of bytes sent.
144 Otherwise, \fB-1\fR is returned and \fBerrno\fR is set to indicate the error.
145 .SH ERRORS
148 The \fBsendto()\fR function will fail if:
150 .ne 2
152 \fB\fBEAFNOSUPPORT\fR\fR
154 .RS 16n
155 Addresses in the specified address family cannot be used with this socket.
159 .ne 2
161 \fB\fBEAGAIN\fR\fR
165 \fB\fBEWOULDBLOCK\fR\fR
167 .RS 16n
168 The socket's file descriptor is marked \fBO_NONBLOCK\fR and the requested
169 operation would block.
173 .ne 2
175 \fB\fBEBADF\fR\fR
177 .RS 16n
178 The \fIsocket\fR argument is not a valid file descriptor.
182 .ne 2
184 \fB\fBECONNRESET\fR\fR
186 .RS 16n
187 A connection was forcibly closed by a peer.
191 .ne 2
193 \fB\fBEFAULT\fR\fR
195 .RS 16n
196 The  \fImessage\fR or  \fIdestaddr\fR parameter cannot be accessed.
200 .ne 2
202 \fB\fBEINTR\fR\fR
204 .RS 16n
205 A signal interrupted \fBsendto()\fR before any data was transmitted.
209 .ne 2
211 \fB\fBEMSGSIZE\fR\fR
213 .RS 16n
214 The message is too large to be sent all at once, as the socket requires.
218 .ne 2
220 \fB\fBENOTCONN\fR\fR
222 .RS 16n
223 The socket is connection-mode but is not connected.
227 .ne 2
229 \fB\fBENOTSOCK\fR\fR
231 .RS 16n
232 The \fIsocket\fR argument does not refer to a socket.
236 .ne 2
238 \fB\fBEOPNOTSUPP\fR\fR
240 .RS 16n
241 The \fIsocket\fR argument is associated with a socket that does not support one
242 or more of the values set in \fIflags\fR.
246 .ne 2
248 \fB\fBEPIPE\fR\fR
250 .RS 16n
251 The socket is shut down for writing, or the socket is connection-mode and is no
252 longer connected. In the latter case, and if the socket is of type
253 \fBSOCK_STREAM\fR, the \fBSIGPIPE\fR signal is generated to the calling thread.
258 If the address family of the socket is \fBAF_UNIX\fR, then \fBsendto()\fR will
259 fail if:
261 .ne 2
263 \fB\fBEIO\fR\fR
265 .RS 16n
266 An I/O error occurred while reading from or writing to the file system.
270 .ne 2
272 \fB\fBELOOP\fR\fR
274 .RS 16n
275 Too many symbolic links were encountered in translating the pathname in the
276 socket address.
280 .ne 2
282 \fB\fBENAMETOOLONG\fR\fR
284 .RS 16n
285 A component of a pathname exceeded \fINAME_MAX\fR characters, or an entire
286 pathname exceeded \fIPATH_MAX\fR characters.
290 .ne 2
292 \fB\fBENOENT\fR\fR
294 .RS 16n
295 A component of the pathname does not name an existing file or the pathname is
296 an empty string.
300 .ne 2
302 \fB\fBENOTDIR\fR\fR
304 .RS 16n
305 A component of the path prefix of the pathname in the socket address is not a
306 directory.
311 The \fBsendto()\fR function may fail if:
313 .ne 2
315 \fB\fBEACCES\fR\fR
317 .RS 16n
318 Search permission is denied for a component of the path prefix; or write access
319 to the named socket is denied.
323 .ne 2
325 \fB\fBEDESTADDRREQ\fR\fR
327 .RS 16n
328 The socket is not connection-mode and does not have its peer address set, and
329 no destination address was specified.
333 .ne 2
335 \fB\fBEHOSTUNREACH\fR\fR
337 .RS 16n
338 The destination host cannot be reached (probably because the host is down or a
339 remote router cannot reach it).
343 .ne 2
345 \fB\fBEINVAL\fR\fR
347 .RS 16n
348 The \fIdest_len\fR argument is not a valid length for the address family.
352 .ne 2
354 \fB\fBEIO\fR\fR
356 .RS 16n
357 An I/O error occurred while reading from or writing to the file system.
361 .ne 2
363 \fB\fBEISCONN\fR\fR
365 .RS 16n
366 A destination address was specified and the socket is already connected.
370 .ne 2
372 \fB\fBENETDOWN\fR\fR
374 .RS 16n
375 The local interface used to reach the destination is down.
379 .ne 2
381 \fB\fBENETUNREACH\fR\fR
383 .RS 16n
384 No route to the network is present.
388 .ne 2
390 \fB\fBENOBUFS\fR\fR
392 .RS 16n
393 Insufficient resources were available in the system to perform the operation.
397 .ne 2
399 \fB\fBENOMEM\fR\fR
401 .RS 16n
402 Insufficient memory was available to fulfill the request.
406 .ne 2
408 \fB\fBENOSR\fR\fR
410 .RS 16n
411 There were insufficient STREAMS resources available for the operation to
412 complete.
417 If the address family of the socket is \fBAF_UNIX\fR, then \fBsendto()\fR may
418 fail if:
420 .ne 2
422 \fB\fBENAMETOOLONG\fR\fR
424 .RS 16n
425 Pathname resolution of a symbolic link produced an intermediate result whose
426 length exceeds \fIPATH_MAX\fR.
429 .SH ATTRIBUTES
432 See \fBattributes\fR(5) for descriptions of the following attributes:
437 box;
438 c | c
439 l | l .
440 ATTRIBUTE TYPE  ATTRIBUTE VALUE
442 Interface Stability     Standard
444 MT-Level        MT-Safe
447 .SH SEE ALSO
450 \fBpoll\fR(2), \fBgetsockopt\fR(3XNET), \fBrecv\fR(3XNET),
451 \fBrecvfrom\fR(3XNET), \fBrecvmsg\fR(3XNET), \fBselect\fR(3C),
452 \fBsend\fR(3XNET), \fBsendmsg\fR(3XNET), \fBsetsockopt\fR(3XNET),
453 \fBshutdown\fR(3XNET), \fBsocket\fR(3XNET), \fBattributes\fR(5),
454 \fBstandards\fR(5)