.TH send() "" "" "Sockets Function (libsocket)"
.PC "Send a message to a socket"
.B "#include <sys/socket.h>"
.B "#include <sys/types.h>"
\fBint send(\fIsocket\^\fB, \fImessage\^\fB, \fIlength\^\fB, \fIflags\^\fB)\fR
\fBint \fIsocket\^\fB;\fR
\fBchar *\fImessage\^\fB;\fR
\fBint \fIlength\^\fB, \fIflags\^\fB;\fR
.PP
The function
.B send()
sends a message to a socket.
.PP
.I socket
is the socket to which the messages are sent.
It must have been created by the function
.BR socket() ,
and connected by the function
.BR connect() .
.I buffer
points to the chunk of memory that holds the message to be sent;
.I length
gives the amount of allocated memory to which
.I buffer
points.
.PP
.I flags
ORs together either or both of the following flags:
.IP \fBMSG_OOB\fR
Send ``out-of-band'' data on sockets that support this notion.
The underlying protocol must also support out-of-band data.
.\"Currently, only SOCK_STREAM sockets created in the AF_INET address
.\" family support out-of-band data.
.IP \fBMSG_DONTROUTE\fR
The socket turned on for the duration of the operation.
It is used only by diagnostic or routing programs.
.PP
If all goes well,
.B send()
returns the number of bytes it sent.
If something goes wrong, it returns \-1 and sets
.B errno
to one of the following values:
.IP \fBEAGAIN\fR
If
.I socket
has no buffer space available,
.B send()
normally waits until space becomes available (which is a blocking operation).
.IR socket ,
however, is marked as non-blocking.
.IP \fBEBADF\fR
.I socket
does not identify a valid socket.
.IP \fBEINTR\fR
A signal interrupted
.B send()
before it could send any data.
.IP \fBEMSGSIZE\fR
.I socket
requires that message be sent atomically, and the message was too long.
.IP \fBENOMEM\fR
Insufficient user memory was available to complete the operation.
.\" .IP \fBENOSR\fR
.\" Insufficient \*(ST resouces were available to complete the operation.
.IP ENOTSOCK\fR
.I socket
describes a file, not a socket.
.IP \fBEPROTO\fR
A protocol error has occurred.
.SH "See Also"
.Xr "connect()," connect
.Xr "libsocket," libsocket
.Xr "recv()," recv
.Xr "sendto()," sendto
.Xr "socket()" socket
