SEND(2) Series 300 Only SEND(2)
NAME
send, sendto - send a message from a socket
SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
cc = send(s, msg, len, flags)
int cc, s;
char *msg;
int len, flags;
cc = sendto(s, msg, len, flags, to, tolen)
int cc, s;
char *msg;
int len, flags;
struct sockaddr *to;
int tolen;
HP-UX COMPATIBILITY
Level: HP-UX/NON-STANDARD
Origin: UCB
Remarks: Implemented on the Series 300 only.
DESCRIPTION
Send and sendto are used to transmit a message to another
socket.
S is a socket descriptor which specifies the socket on which
the message will be sent. Msg points to the buffer which
contains the message.
If the socket uses connection-based communications, such as
a SOCK_STREAM socket, these calls may only be used after the
connection has been established (see connect(2)). In this
case, any destination specified by to will be ignored. For
connection-less sockets, such as SOCK_DGRAM, sendto must be
used unless the destination address has already been
specified by connect(2), in which case send may be used, and
if any address is specified by to, an error will be
generated.
The address of the target is contained in a socket address
structure pointed at by to with tolen specifying the size of
the structure.
If a sendto is attempted on a SOCK_DGRAM socket before any
local address has been bound to it, the sytem will
automatically select a local address to be used for the
message. In this case, there is no guarantee that the same
Hewlett-Packard - 1 - (printed 7/16/86)
SEND(2) Series 300 Only SEND(2)
local address will be used for successive sendto requests on
the same socket.
The length of the message is given by len. The length of
data actually sent is returned in cc. If the message is too
long to pass atomically through the underlying protocol,
then the message is not transmitted, and -1 is returned and
errno is set to EMSGSIZE. For SOCK_DGRAM sockets, this size
is fixed by the implementation (see the ``HARDWARE
DEPENDENCIES'' section below). The same size is used for
SOCK_STREAM sockets only if the socket is marked
nonblocking; otherwise there is no size limit.
No indication of failure to deliver is implicit in a
send/sendto. Return values of -1 indicate some locally
detected errors.
If no messages space is available at the socket to hold the
message to be transmitted, then send normally blocks, unless
the socket has been placed in non-blocking i/o mode (see
socket(4)). The select(2) call may be used to determine
when it is possible to send more data by selecting the
socket for writing.
There are no supported values for flags except zero. A
write(2) call made to a socket will behave in exactly the
same way as a send call with flags set to zero.
The call to send or sendto will fail if:
[EBADF] An invalid descriptor was
specified.
[ENOTSOCK] The argument s is not a socket.
[EFAULT] The msg or to parameters are not
valid pointers.
[EMSGSIZE] The socket requires that message
be sent atomically, and the size
of the message to be sent made
this impossible.
[EWOULDBLOCK] The socket is marked non-blocking
and the requested operation would
block.
[ENOBUFS] Insufficient resources were
available in the system to
perform the operation.
[EINTR] The operation was interrupted by
Hewlett-Packard - 2 - (printed 7/16/86)
SEND(2) Series 300 Only SEND(2)
a signal before any data was
sent. If some of the data was
sent, cc will contain the number
of bytes sent before the signal
and EINTR will not be given.
[EINVAL] The len or tolen parameters
contain a bad value.
[EDESTADDRREQ] The to parameter needs to specify
a destination address for the
message. This is also given if
the specified address contains
unspecified fields (see
inet(4F)).
[ENOTCONN] A send on a socket that is not
connected, or a send on a socket
that has not completed the
connect sequence with its peer.
[EISCONN] An address was specified by to
for a SOCK_DGRAM socket which is
already connected.
[EAFNOSUPPORT] Requested address does not match
the address family of this
socket.
[EPIPE and SIGPIPE signal] An attempt is made to send on a
socket that was connected, but
the connection has been shutdown
either by the remote peer or by
this side of the connection.
[ENET] A hardware error is detected on
the interface card.
RETURN VALUE
The call returns the number of characters sent, or -1 if an
error occurred.
SEE ALSO
recv(2), select(2), socket(2), inet(4F), socket(4).
HARDWARE DEPENDENCIES
Series 300:
The maximum size message which may be sent on a
SOCK_DGRAM socket (or a nonblocking SOCK_STREAM socket)
is 2860 bytes.
Hewlett-Packard - 3 - (printed 7/16/86)