send.2 (2010 09)

s
send(2) send(2)
NAME
send(), sendmsg(), sendto() - send a message from a socket
SYNOPSIS
#include <sys/socket.h>
int send(int s, const void *msg, int len, int flags);
int sendto(
int s,
const void *msg,
int len,
int flags,
const void *to,
int tolen
);
int sendmsg(int s, const struct msghdr msg[], int flags);
UNIX 03 Only (X/Open Sockets)
ssize_t send(int s, const void *msg, size_t len, int flags);
ssize_t sendto(
int s,
const void *msg,
size_t len,
int flags,
const struct sockaddr *to,
socklen_t tolen
);
ssize_t sendmsg(int s, const struct msghdr *msg, int flags);
Obsolescent UNIX 95 Only (X/Open Sockets)
ssize_t sendto(
int s,
const void *msg,
size_t len,
int flags,
const struct sockaddr *to,
size_t tolen
);
DESCRIPTION
The send(), sendmsg(), and sendto() system calls transmit a message to another socket. send()
can be used only when the socket is in a connected state, whereas sendmsg() and sendto() can be
used at any time. sendmsg() allows the send data to be gathered from several buffers specified in the
msghdr structure.
s is a socket descriptor that specifies the socket on which the message will be sent.
msg points to the buffer containing the message.
If the socket uses connection-based communications, such as a SOCK_STREAM socket, these calls can
only be used after the connection has been established (see connect (2)). In this case, any destination
specified by to is ignored. For connectionless sockets, such as SOCK_DGRAM,
sendto() must be used
unless the destination address has already been specified by connect(). If the destination address has
been specified and sendto() is used, an error results if any address is specified by to.
The address of the target socket is contained in a socket address structure pointed to 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 system automatically selects a local address to be used for the message. In this case, there is no
guarantee that the same local address will be used for successive sendto() requests on the same socket.
The length of the message is given by len in bytes. The length of data actually sent is returned. If the
message is too long to pass atomically through the underlying protocol, the message is not transmitted,
HP-UX 11i Version 3: September 2010 1 Hewlett-Packard Company 1

Summary of content (6 pages)