send

Top  Previous  Next

The send function sends data on a connected socket.

Successful completion of a call to send does not guarantee delivery of the message. A return value of -1 indicates only locally-detected errors.

If space is not available at the sending socket to hold the message to be transmitted, send blocks until space is available.

 

Syntax

ssize_t send(

int socket,

const void *buf,

size_t len,

int flags

);

 

Parameters

socket

The descriptor that identifies a connected socket.

 

buf

A pointer to a buffer containing the data to be transmitted.

 

len

The length, in bytes, of the data in buffer pointed to by the buf parameter.  If the message is too long to pass through the underlying protocol, send fails and no data is transmitted.

 

flags

A set of flags that specify the way in which the call is made. This parameter is constructed by using the bitwise OR operator with any of the following values.

 

Type

Meaning

MSG_OOB

Sends out-of-band data in sockets that support out of band communications. The significance and semantics of out-of band data are protocol-specific.

MSG_WAITALL

Terminates a record (if supported by the protocol).

 

Return value

Upon successful completion, send returns the number of bytes sent. Otherwise, -1 is returned and errno set to indicate the error.