OSDN Git Service

LDP: Update original to LDP v3.79
[linuxjm/LDP_man-pages.git] / original / man2 / send.2
index eaeeb3a..108c046 100644 (file)
@@ -1,6 +1,7 @@
 .\" Copyright (c) 1983, 1991 The Regents of the University of California.
 .\" All rights reserved.
 .\"
+.\" %%%LICENSE_START(BSD_4_CLAUSE_UCB)
 .\" Redistribution and use in source and binary forms, with or without
 .\" modification, are permitted provided that the following conditions
 .\" are met:
@@ -28,6 +29,7 @@
 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
+.\" %%%LICENSE_END
 .\"
 .\" Modified 1993-07-24 by Rik Faith <faith@cs.unc.edu>
 .\" Modified 1996-10-22 by Eric S. Raymond <esr@thyrsus.com>
@@ -35,7 +37,7 @@
 .\" Modified Oct 2003 by aeb
 .\" Modified 2004-07-01 by mtk
 .\"
-.TH SEND 2 2012-02-27 "Linux" "Linux Programmer's Manual"
+.TH SEND 2 2014-08-19 "Linux" "Linux Programmer's Manual"
 .SH NAME
 send, sendto, sendmsg \- send a message on a socket
 .SH SYNOPSIS
@@ -155,14 +157,14 @@ in this case.
 The
 .BR select (2)
 call may be used to determine when it is possible to send more data.
-.PP
+.SS The flags argument
 The
 .I flags
 argument is the bitwise OR
 of zero or more of the following flags.
-.\" FIXME ? document MSG_PROXY (which went away in 2.3.15)
+.\" FIXME ? document MSG_PROXY (which went away in 2.3.15)
 .TP
-.BR MSG_CONFIRM " (Since Linux 2.3.15)"
+.BR MSG_CONFIRM " (since Linux 2.3.15)"
 Tell the link layer that forward progress happened: you got a successful
 reply from the other side.
 If the link layer doesn't get this
@@ -171,17 +173,17 @@ Only valid on
 .B SOCK_DGRAM
 and
 .B SOCK_RAW
-sockets and currently only implemented for IPv4 and IPv6.
+sockets and currently implemented only for IPv4 and IPv6.
 See
 .BR arp (7)
 for details.
 .TP
 .B MSG_DONTROUTE
-Don't use a gateway to send out the packet, only send to hosts on
+Don't use a gateway to send out the packet, send to hosts only on
 directly connected networks.
 This is usually used only
 by diagnostic or routing programs.
-This is only defined for protocol
+This is defined only for protocol
 families that route; packet sockets don't.
 .TP
 .BR MSG_DONTWAIT " (since Linux 2.2)"
@@ -199,7 +201,7 @@ flag with the
 Terminates a record (when this notion is supported, as for sockets of type
 .BR SOCK_SEQPACKET ).
 .TP
-.BR MSG_MORE " (Since Linux 2.4.4)"
+.BR MSG_MORE " (since Linux 2.4.4)"
 The caller has more data to send.
 This flag is used with TCP sockets to obtain the same effect
 as the
@@ -210,7 +212,7 @@ with the difference that this flag can be set on a per-call basis.
 
 Since Linux 2.6, this flag is also supported for UDP sockets, and informs
 the kernel to package all of the data sent in calls with this flag set
-into a single datagram which is only transmitted when a call is performed
+into a single datagram which is transmitted only when a call is performed
 that does not specify this flag.
 (See also the
 .B UDP_CORK
@@ -234,13 +236,12 @@ data on sockets that support this notion (e.g., of type
 the underlying protocol must also support
 .I out-of-band
 data.
-.PP
+.SS sendmsg()
 The definition of the
 .I msghdr
-structure follows.
-See
-.BR recv (2)
-and below for an exact description of its fields.
+structure employed by
+.BR sendmsg ()
+is as follows:
 .in +4n
 .nf
 
@@ -251,11 +252,28 @@ struct msghdr {
     size_t        msg_iovlen;     /* # elements in msg_iov */
     void         *msg_control;    /* ancillary data, see below */
     size_t        msg_controllen; /* ancillary data buffer len */
-    int           msg_flags;      /* flags on received message */
+    int           msg_flags;      /* flags (unused) */
 };
 .fi
 .in
 .PP
+The
+.I msg_name
+field is used on an unconnected socket to specify the target
+address for a datagram.
+It points to a buffer containing the address; the
+.I msg_namelen
+field should be set to the size of the address.
+For a connected socket, these fields should be specified as NULL and 0,
+respectively.
+
+The
+.I msg_iov
+and
+.I msg_iovlen
+fields specify scatter-gather locations, as for
+.BR writev (2).
+
 You may send control information using the
 .I msg_control
 and
@@ -266,12 +284,15 @@ per socket by the value in
 .IR /proc/sys/net/core/optmem_max ;
 see
 .BR socket (7).
+
+The
+.I msg_flags
+field is ignored.
 .\" Still to be documented:
 .\"  Send file descriptors and user credentials using the
 .\"  msg_control* fields.
-.\"  The flags returned in msg_flags.
-.SH "RETURN VALUE"
-On success, these calls return the number of characters sent.
+.SH RETURN VALUE
+On success, these calls return the number of bytes sent.
 On error, \-1 is returned, and
 .I errno
 is set appropriately.
@@ -288,6 +309,9 @@ or search permission is denied for one of the directories
 the path prefix.
 (See
 .BR path_resolution (7).)
+.sp
+(For UDP sockets) An attempt was made to send to a
+network/broadcast address as though it was a unicast address.
 .TP
 .BR EAGAIN " or " EWOULDBLOCK
 .\" Actually EAGAIN on Linux
@@ -297,6 +321,19 @@ POSIX.1-2001 allows either error to be returned for this case,
 and does not require these constants to have the same value,
 so a portable application should check for both possibilities.
 .TP
+.B EAGAIN
+(Internet domain datagram sockets)
+The socket referred to by
+.I sockfd
+had not previously been bound to an address and,
+upon attempting to bind it to an ephemeral port,
+it was determined that all port numbers in the ephemeral port range
+are currently in use.
+See the discussion of
+.I /proc/sys/net/ipv4/ip_local_port_range
+in
+.BR ip (7).
+.TP
 .B EBADF
 An invalid descriptor was specified.
 .TP
@@ -354,17 +391,17 @@ argument is inappropriate for the socket type.
 .TP
 .B EPIPE
 The local end has been shut down on a connection oriented socket.
-In this case the process
+In this case, the process
 will also receive a
 .B SIGPIPE
 unless
 .B MSG_NOSIGNAL
 is set.
-.SH "CONFORMING TO"
+.SH CONFORMING TO
 4.4BSD, SVr4, POSIX.1-2001.
 These function calls appeared in 4.2BSD.
 .LP
-POSIX.1-2001 only describes the
+POSIX.1-2001 describes only the
 .B MSG_OOB
 and
 .B MSG_EOR
@@ -375,19 +412,6 @@ The
 .B MSG_CONFIRM
 flag is a Linux extension.
 .SH NOTES
-The prototypes given above follow the Single UNIX Specification,
-as glibc2 also does; the
-.I flags
-argument was \fIint\fP in 4.x BSD, but \fIunsigned int\fP in libc4 and libc5;
-the
-.I len
-argument was \fIint\fP in 4.x BSD and libc4, but \fIsize_t\fP in libc5;
-the
-.I addrlen
-argument was \fIint\fP in 4.x BSD and libc4 and libc5.
-See also
-.BR accept (2).
-
 According to POSIX.1-2001, the
 .I msg_controllen
 field of the
@@ -403,7 +427,7 @@ but glibc currently types it as
 .\" across architectures, but socklen_t is always 32 bits.
 
 See
-.BR sendmmsg(2)
+.BR sendmmsg (2)
 for information about a Linux-specific system call
 that can be used to transmit multiple datagrams in a single call.
 .SH BUGS
@@ -416,7 +440,7 @@ An example of the use of
 .BR sendto ()
 is shown in
 .BR getaddrinfo (3).
-.SH "SEE ALSO"
+.SH SEE ALSO
 .BR fcntl (2),
 .BR getsockopt (2),
 .BR recv (2),
@@ -431,3 +455,12 @@ is shown in
 .BR socket (7),
 .BR tcp (7),
 .BR udp (7)
+.SH COLOPHON
+This page is part of release 3.79 of the Linux
+.I man-pages
+project.
+A description of the project,
+information about reporting bugs,
+and the latest version of this page,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.