UDT Reference: UDT Functions

recvmsg

The recvmsg method receives a valid message.

int recvmsg(
  UDTSOCKET u,

  char *buf,
  int len

);

Parameters

u
[in] Descriptor identifying a connected socket.
buf
[out] Buffer used to store the message.
len
[in] Length of the buffer to store the message.

Return Values

On success, the actual size of received data is returned; Otherwise, UDT::ERROR is returned and the specific error information can be retrieved by getlasterror. If UDT_RCVTIMEO is set to a positive value, zero will be returned if no data is received before the timer expires.

Error Code Comment

2001

connection broken before send is completed.

2002

u is not connected.

5004

u is an invalid UDT socket.

5009

cannot use recvmsg in SOCK_STREAM mode.

6002

no data is available to be received on a non-blocking socket.

6003 no buffer available for the non-blocking recv call.

6004

an overlapped recv is in progress.

Description

The recvmsg method retrieves the first valid message from the received message pool. If there is no valid messages, recvmsg wait until a valid message is available in blocking mode, or the time specified by UDT_RCVTIMEO expires. In non-blocking mode, recvmsg returns immediately if there is no available message.

If the length of the buffer is shorter than the length of the first available message in the pool, the buffer will by filled by part of the message (starting continuously from the first byte of the message). The rest of the message will be discarded and will NOT be available for future read.

See Also

select, send, sendmsg, sendfile, recvfile, getoverlappedresult