mirror of
https://github.com/GnoConsortium/gno.git
synced 2024-12-23 05:30:18 +00:00
188 lines
5.6 KiB
Groff
188 lines
5.6 KiB
Groff
|
.\" Copyright (c) 1983, 1991, 1993
|
||
|
.\" The Regents of the University of California. All rights reserved.
|
||
|
.\"
|
||
|
.\" Redistribution and use in source and binary forms, with or without
|
||
|
.\" modification, are permitted provided that the following conditions
|
||
|
.\" are met:
|
||
|
.\" 1. Redistributions of source code must retain the above copyright
|
||
|
.\" notice, this list of conditions and the following disclaimer.
|
||
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
||
|
.\" notice, this list of conditions and the following disclaimer in the
|
||
|
.\" documentation and/or other materials provided with the distribution.
|
||
|
.\" 3. All advertising materials mentioning features or use of this software
|
||
|
.\" must display the following acknowledgement:
|
||
|
.\" This product includes software developed by the University of
|
||
|
.\" California, Berkeley and its contributors.
|
||
|
.\" 4. Neither the name of the University nor the names of its contributors
|
||
|
.\" may be used to endorse or promote products derived from this software
|
||
|
.\" without specific prior written permission.
|
||
|
.\"
|
||
|
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||
|
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||
|
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||
|
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||
|
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||
|
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||
|
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||
|
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||
|
.\" 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.
|
||
|
.\"
|
||
|
.\" From: @(#)send.2 8.2 (Berkeley) 2/21/94
|
||
|
.\" $Id: send.2,v 1.1 1997/02/27 07:32:15 gdr Exp $
|
||
|
.\"
|
||
|
.TH SEND 2 "16 January 1997" GNO "System Calls"
|
||
|
.SH NAME
|
||
|
.BR send ,
|
||
|
.BR sendto ,
|
||
|
.BR sendmsg
|
||
|
\- send a message from a socket
|
||
|
.SH SYNOPSIS
|
||
|
.br
|
||
|
#include <sys/types.h>
|
||
|
.br
|
||
|
#include <sys/socket.h>
|
||
|
.sp 1
|
||
|
int
|
||
|
\fBsend\fR (int \fIs\fR, const void *\fImsg\fR, size_t \fIlen\fR,
|
||
|
unsigned int \fIflags\fR);
|
||
|
.sp 1
|
||
|
int
|
||
|
\fBsendto\fR (int \fIs\fR, const void *\fImsg\fR, size_t \fIlen\fR,
|
||
|
int \fIflags\fR, const struct sockaddr *\fIto\fR, unsigned int \fItolen\fR);
|
||
|
.sp 1
|
||
|
int
|
||
|
\fBsendmsg\fR (int \fIs\fR, const struct msghdr *\fImsg\fR,
|
||
|
unsigned int \fIflags\fR);
|
||
|
.SH DESCRIPTION
|
||
|
.BR Send ,
|
||
|
.BR sendto ,
|
||
|
and
|
||
|
.BR sendmsg
|
||
|
are used to transmit a message to another socket.
|
||
|
.BR Send
|
||
|
may be used only when the socket is in a
|
||
|
.IR connected
|
||
|
state, while
|
||
|
.BR sendto
|
||
|
and
|
||
|
.BR sendmsg
|
||
|
may be used at any time.
|
||
|
.LP
|
||
|
The address of the target is given by
|
||
|
.I to
|
||
|
with
|
||
|
.I tolen
|
||
|
specifying its size.
|
||
|
The length of the message is given by
|
||
|
.RI ( len )
|
||
|
If the message is too long to pass atomically through the
|
||
|
underlying protocol, the error
|
||
|
EMSGSIZE
|
||
|
is returned, and
|
||
|
the message is not transmitted.
|
||
|
.LP
|
||
|
No indication of failure to deliver is implicit in a
|
||
|
.BR send .
|
||
|
Locally detected errors are indicated by a return value of -1.
|
||
|
.LP
|
||
|
If no messages space is available at the socket to hold
|
||
|
the message to be transmitted, then
|
||
|
.BR send
|
||
|
normally blocks, unless the socket has been placed in
|
||
|
non-blocking I/O mode.
|
||
|
The
|
||
|
.BR select (2)
|
||
|
call may be used to determine when it is possible to
|
||
|
send more data.
|
||
|
.LP
|
||
|
The
|
||
|
.I flags
|
||
|
parameter may include one or more of the following:
|
||
|
.nf
|
||
|
|
||
|
#define MSG_OOB 0x1 /* process out-of-band data */
|
||
|
#define MSG_PEEK 0x2 /* peek at incoming message */
|
||
|
#define MSG_DONTROUTE 0x4 /* bypass routing, use direct interface */
|
||
|
#define MSG_EOR 0x8 /* data completes record */
|
||
|
#define MSG_EOF 0x100 /* data completes transaction */
|
||
|
.fi
|
||
|
.LP
|
||
|
The flag
|
||
|
.BR MSG_OOB
|
||
|
is used to send
|
||
|
.I out-of-band
|
||
|
data on sockets that support this notion (e.g.
|
||
|
.BR SOCK_STREAM ) ;
|
||
|
the underlying protocol must also support
|
||
|
.I out-of-band
|
||
|
data.
|
||
|
.BR MSG_EOR
|
||
|
is used to indicate a record mark for protocols which support the
|
||
|
concept.
|
||
|
.BR MSG_EOF
|
||
|
requests that the sender side of a socket be shut down, and that an
|
||
|
appropriate indication be sent at the end of the specified data;
|
||
|
this flag is only implemented for
|
||
|
.BR SOCK_STREAM
|
||
|
sockets in the
|
||
|
.BR PF_INET
|
||
|
protocol family, and is used to implement Transaction TCP (see
|
||
|
.BR ttcp (4)).
|
||
|
.BR MSG_DONTROUTE
|
||
|
is usually used only by diagnostic or routing programs.
|
||
|
.LP
|
||
|
See
|
||
|
.BR recv (2)
|
||
|
for a description of the
|
||
|
.I msghdr
|
||
|
structure.
|
||
|
.SH RETURN VALUES
|
||
|
The call returns the number of characters sent, or -1
|
||
|
if an error occurred.
|
||
|
.SH ERRORS
|
||
|
.BR Send ,
|
||
|
.BR sendto ,
|
||
|
and
|
||
|
.BR sendmsg
|
||
|
fail if:
|
||
|
.RS
|
||
|
.IP \fBEBADF\fR
|
||
|
An invalid descriptor was specified.
|
||
|
.IP \fBENOTSOCK\fR
|
||
|
The argument
|
||
|
.I s
|
||
|
is not a socket.
|
||
|
.IP \fBEFAULT\fR
|
||
|
An invalid user space address was specified for a parameter.
|
||
|
.IP \fBEMSGSIZE\fR
|
||
|
The socket requires that message be sent atomically,
|
||
|
and the size of the message to be sent made this impossible.
|
||
|
.IP \fBEAGAIN\fR
|
||
|
The socket is marked non-blocking and the requested operation
|
||
|
would block.
|
||
|
.IP \fBENOBUFS\fR
|
||
|
The system was unable to allocate an internal buffer.
|
||
|
The operation may succeed when buffers become available.
|
||
|
.IP \fBENOBUFS\fR
|
||
|
The output queue for a network interface was full.
|
||
|
This generally indicates that the interface has stopped sending,
|
||
|
but may be caused by transient congestion.
|
||
|
.RE
|
||
|
.SH CONVORMANCE
|
||
|
The GNO prototypes of these routines differ slightly from that of
|
||
|
4.4BSD.
|
||
|
.SH SEE ALSO
|
||
|
.BR fcntl (2),
|
||
|
.BR recv (2),
|
||
|
.BR select (2),
|
||
|
.BR getsockopt (2),
|
||
|
.BR socket (2),
|
||
|
.BR write (2)
|
||
|
.SH HISTORY
|
||
|
The
|
||
|
.BR sendmsg
|
||
|
function call appeared in 4.2BSD.
|
||
|
The first appearance in GNO was in v2.0.5.
|