The recvmsg method receives a valid message.
On success, recvmsg returns the actual size of received message. Otherwise UDT::ERROR is returned and specific error information can be retrieved by getlasterror. If UDT_RCVTIMEO is set to a positive value, zero will be returned if no message is received before the timer expires.
Error Name | Error Code | Comment |
ECONNLOST | 2001 | connection has been broken and no data left in receiver buffer. |
ENOCONN | 2002 | u is not connected. |
EINVSOCK | 5004 | u is not an valid socket. |
ESTREAMILL | 5009 | cannot use recvmsg in SOCK_STREAM mode. |
EASYNCRCV | 6002 | u is non-blocking (UDT_RCVSYN = false) but no message is available. |
ETIMEOUT | 6003 | Timeout on UDT_RCVTIMEO . |
The recvmsg method reads a message from the protocol buffer. The UDT socket must be in SOCK_DGRAM mode in order to send or receive messages. Message is the minimum data unit in this situation. Each recvmsg will read no more than one message, even if the message is smaller than the size of buf and there are more messages available. On the other hand, if the buf is not enough to hold the first message, only part of the message will be copied into the buffer, but the message will still be discarded after this recvmsg call.
In blocking mode (default), recvmsg waits until there is a valid message received into the receiver buffer. In non-blocking mode, recvmsg returns immediately and returns error if no message available.
If UDT_RCVTIMEO is set and the socket is in blocking mode, recvmsg only waits a limited time specified by UDT_RCVTIMEO option. If there is still no message available when the timer expires, error will be returned. UDT_RCVTIMEO has no effect for non-blocking socket.