1SEND(2)                       System Calls Manual                      SEND(2)
2
3
4

NAME

6       send, sendto, sendmsg - send a message from a socket
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <sys/socket.h>
11
12       cc = send(s, msg, len, flags)
13       int cc, s;
14       char *msg;
15       int len, flags;
16
17       cc = sendto(s, msg, len, flags, to, tolen)
18       int cc, s;
19       char *msg;
20       int len, flags;
21       struct sockaddr *to;
22       int tolen;
23
24       cc = sendmsg(s, msg, flags)
25       int cc, s;
26       struct msghdr msg[];
27       int flags;
28

DESCRIPTION

30       Send,  sendto,  and  sendmsg  are used to transmit a message to another
31       socket.  Send may be used only when the socket is in a connected state,
32       while sendto and sendmsg may be used at any time.
33
34       The  address  of  the  target  is given by to with tolen specifying its
35       size.  The length of the message is given by len.  If  the  message  is
36       too  long  to pass atomically through the underlying protocol, then the
37       error EMSGSIZE is returned, and the message is not transmitted.
38
39       No indication of failure to deliver is implicit in a send.  Return val‐
40       ues of -1 indicate some locally detected errors.
41
42       If  no messages space is available at the socket to hold the message to
43       be transmitted, then send normally blocks, unless the socket  has  been
44       placed  in  non-blocking  I/O  mode.  The select(2) call may be used to
45       determine when it is possible to send more data.
46
47       The flags parameter may include one or more of the following:
48
49              #define  MSG_OOB         0x1    /* process out-of-band data */
50              #define  MSG_DONTROUTE   0x4    /* bypass routing, use direct interface */
51       The flag MSG_OOB is used to send “out-of-band”  data  on  sockets  that
52       support  this  notion  (e.g. SOCK_STREAM); the underlying protocol must
53       also support “out-of-band” data.  MSG_DONTROUTE is usually used only by
54       diagnostic or routing programs.
55
56       See recv(2) for a description of the msghdr structure.
57

RETURN VALUE

59       The  call  returns  the  number  of  characters sent, or -1 if an error
60       occurred.
61

ERRORS

63       [EBADF]             An invalid descriptor was specified.
64
65       [ENOTSOCK]          The argument s is not a socket.
66
67       [EFAULT]            An invalid user space address was specified  for  a
68                           parameter.
69
70       [EMSGSIZE]          The  socket  requires  that  message be sent atomi‐
71                           cally, and the size of the message to be sent  made
72                           this impossible.
73
74       [EWOULDBLOCK]       The socket is marked non-blocking and the requested
75                           operation would block.
76
77       [ENOBUFS]           The system was unable to allocate an internal  buf‐
78                           fer.  The operation may succeed when buffers become
79                           available.
80
81       [ENOBUFS]           The output queue for a network interface was  full.
82                           This  generally  indicates  that  the interface has
83                           stopped sending, but may  be  caused  by  transient
84                           congestion.
85

SEE ALSO

87       fcntl(2), recv(2), select(2), getsockopt(2), socket(2), write(2)
88
89
90
914.2 Berkeley Distribution        May 14, 1986                          SEND(2)
Impressum