DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

send(SSC)


send, sendto, sendmsg -- send a message to a socket

Syntax

cc ... -lsocket

#include <sys/types.h>
#include <sys/socket.h>

int send(s, msg, len, flags) int s; const void *msg; int len, flags;

int sendto(s, msg, len, flags, to, tolen) int s; const void *msg; int len, flags; const struct sockaddr *to; int tolen;

int sendmsg(s, msg, flags) int s; const struct msghdr *msg; int flags;

Description

send( ), sendto( ), and sendmsg( ) are used to transmit a message to another socket(s). send( ) may be used only when the socket is in a connected state, while sendto( ) and sendmsg( ) may be used at any time.

The address of the target is given by to with tolen specifying its size. The length of the message is given by len. If the message is too long to pass atomically through the underlying protocol, then the error EMSGSIZE is returned, and the message is not transmitted.

No indication of failure to deliver is implicit in a send( ). Return values of -1 indicate some locally detected errors.

If no message space is available at the socket to hold the message to be transmitted, then send( ) blocks.

The flags parameter may be set to one of the following:


MSG_OOB
send ``out-of-band'' data on sockets which support this notion (for example, SOCK_STREAM).

MSG_DONTROUTE
cause the normal routing lookup to be bypassed. This is primarily intended for debugging and routing applications.

See recv(SSC) for a description of the msghdr structure.

Return values

The call returns the number of characters sent, or -1 if an error occurred.

Diagnostics


[EBADF]
An invalid descriptor was specified.

[ENOTSOCK]
The s argument does not point to a socket.

[EFAULT]
An invalid user space address was specified for a parameter.

[EMSGSIZE]
The socket requires that the message not fragmented, but the message is too large to avoid fragmentation.

See also

Intro(ADMP), Intro(SSC), connect(SSC), recv(SSC), socket(SSC)
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003