UDT Reference

UDT Reference: Functions

#### send

The send method sends out certain amount of data from an application buffer.

int send(
UDTSOCKET u,
const char* buf,
int len,
int flags
);

##### Parameters

u
  [in] Descriptor identifying a connected socket.
buf
  [in] The buffer of data to be sent.
len
  [in] Length of the buffer.
flags
  [in] Ignored. For compatibility only.

##### Return Value

On success, send returns the actual size of data that has been sent. Otherwise UDT::ERROR is returned and specific error information can be retrieved by getlasterror. If UDT_SNDTIMEO is set to a positive value, zero will be returned if no data is sent before the timer expires.

Error Name | Error Code | Comment
ECONNLOST | 2001 | connection has been broken.
ENOCONN | 2002 | u is not connected.
EINVSOCK | 5004 | u is not an valid socket.
EDGRAMILL | 5010 | cannot use send in SOCK_DGRAM mode.
EASYNCSND | 6001 | u is non-blocking (UDT_SNDSYN = false) but buffer space is available for sending.
ETIMEOUT | 6003 | Timeout on UDT_SNDTIMEO .
EPEERERR | 7000 | The peer side has an unrecoverable error and this call has to be cancelled.

##### Description

The send method sends certain amount of data from the application buffer. If the the size limit of sending buffer queue is reached, send only sends a portion of the application buffer and returns the actual size of data that has been sent.

In blocking mode (default), send waits until there is some sending buffer space available. In non-blocking mode, send returns immediately and returns error if the sending queue limit is already limited.

If UDT_SNDTIMEO is set and the socket is in blocking mode, send only waits a limited time specified by UDT_SNDTIMEO option. If there is still no buffer space available when the timer expires, error will be returned. UDT_SNDTIMEO has no effect for non-blocking socket.

##### See Also

send, sendfile, recvfile