1 |
1254 |
phoenix |
NAME
|
2 |
|
|
sendto - send a message from a socket
|
3 |
|
|
|
4 |
|
|
SYNOPSIS
|
5 |
|
|
#include <network.h>
|
6 |
|
|
|
7 |
|
|
int sendto(int s, const void *msg, int len, unsigned int
|
8 |
|
|
flags, const struct sockaddr *to, int tolen);
|
9 |
|
|
|
10 |
|
|
DESCRIPTION
|
11 |
|
|
Sendto is used to transmit a message
|
12 |
|
|
to another socket.
|
13 |
|
|
|
14 |
|
|
The address of the target is given by to with tolen speci
|
15 |
|
|
fying its size. The length of the message is given by
|
16 |
|
|
len. If the message is too long to pass atomically
|
17 |
|
|
through the underlying protocol, the error EMSGSIZE is
|
18 |
|
|
returned, and the message is not transmitted.
|
19 |
|
|
|
20 |
|
|
No indication of failure to deliver is implicit in a send.
|
21 |
|
|
Locally detected errors are indicated by a return value of
|
22 |
|
|
-1.
|
23 |
|
|
|
24 |
|
|
When the message does not fit into the send buffer of the
|
25 |
|
|
socket, send normally blocks, unless the socket has been
|
26 |
|
|
placed in non-blocking I/O mode. In non-blocking mode it
|
27 |
|
|
would return EAGAIN in this case. The select(2) call may
|
28 |
|
|
be used to determine when it is possible to send more
|
29 |
|
|
data.
|
30 |
|
|
|
31 |
|
|
The flags parameter may include one or more of the follow
|
32 |
|
|
ing:
|
33 |
|
|
|
34 |
|
|
#define MSG_OOB 0x1 /* process out-of-band data */
|
35 |
|
|
#define MSG_DONTROUTE 0x4 /* bypass routing, use direct interface */
|
36 |
|
|
#define MSG_DONTWAIT 0x40 /* don't block */
|
37 |
|
|
#define MSG_NOSIGNAL 0x2000 /* don't raise SIGPIPE */
|
38 |
|
|
|
39 |
|
|
MSG_OOB
|
40 |
|
|
Sends out-of-band data on sockets that support this
|
41 |
|
|
notion (e.g. SOCK_STREAM); the underlying protocol
|
42 |
|
|
must also support out-of-band data.
|
43 |
|
|
|
44 |
|
|
MSG_DONTROUTE
|
45 |
|
|
Bypasses the usual routing table lookup and sends
|
46 |
|
|
the packet directly to the interface described by
|
47 |
|
|
the destination address. This is usually used only
|
48 |
|
|
by diagnostic or routing programs.
|
49 |
|
|
|
50 |
|
|
MSG_DONTWAIT
|
51 |
|
|
Enables non-blocking operation; if the operation
|
52 |
|
|
would block, EAGAIN is returned.
|
53 |
|
|
|
54 |
|
|
MSG_NOSIGNAL
|
55 |
|
|
Requests not to send SIGPIPE on errors on stream
|
56 |
|
|
oriented sockets when the other end breaks the con
|
57 |
|
|
nection. The EPIPE error is still returned.
|
58 |
|
|
|
59 |
|
|
See recv(2) for a description of the msghdr structure. You
|
60 |
|
|
may send control information using the msg_control and
|
61 |
|
|
msg_controllen members. The maximum control buffer length
|
62 |
|
|
the kernel can process is limited by the net.core.opt
|
63 |
|
|
mem_max sysctl; see socket(4).
|
64 |
|
|
|
65 |
|
|
RETURN VALUES
|
66 |
|
|
The calls return the number of characters sent, or -1 if
|
67 |
|
|
an error occurred.
|
68 |
|
|
|
69 |
|
|
ERRORS
|
70 |
|
|
These are some standard errors generated by the socket
|
71 |
|
|
layer. Additional errors may be generated and returned
|
72 |
|
|
from the underlying protocol modules; see their respective
|
73 |
|
|
manual pages.
|
74 |
|
|
|
75 |
|
|
EBADF An invalid descriptor was specified.
|
76 |
|
|
|
77 |
|
|
ENOTSOCK
|
78 |
|
|
The argument s is not a socket.
|
79 |
|
|
|
80 |
|
|
EMSGSIZE
|
81 |
|
|
The socket requires that message be sent atomi
|
82 |
|
|
cally, and the size of the message to be sent made
|
83 |
|
|
this impossible.
|
84 |
|
|
|
85 |
|
|
EAGAIN The socket is marked non-blocking and the
|
86 |
|
|
requested operation would block.
|
87 |
|
|
|
88 |
|
|
ENOBUFS The system was unable to allocate an internal mem
|
89 |
|
|
ory block. The operation may succeed when buffers
|
90 |
|
|
become available.
|
91 |
|
|
|
92 |
|
|
EINTR A signal occurred.
|
93 |
|
|
|
94 |
|
|
ENOMEM No memory available.
|
95 |
|
|
|
96 |
|
|
EINVAL Invalid argument passed.
|
97 |
|
|
|
98 |
|
|
EPIPE The local end has been shut down on a connection
|
99 |
|
|
oriented socket. In this case the process will
|
100 |
|
|
also receive a SIGPIPE unless MSG_NOSIGNAL is set.
|