UDT Reference: UDT Functions

sendmsg

The sendmsg method sends out an application message.

int sendmsg(
  UDTSOCKET u,

  const char *buf,
  int len,
  int ttl = -1,

  bool inorder = false

);

Parameters

u
[in] Descriptor identifying a connected socket.
buf
[in] Buffer containing the message to be transmitted.
len
[in] Length of the data in buf.
ttl
[in] optional. Time-to-live of this message.
inorder
[in] optional. If the message should be delivered in order.

Return Values

On success, the actual size of data sent is returned; Otherwise, UDT::ERROR is returned and the specific error information can be retrieved by getlasterror. The UDT_SNDTIMEO will be overwritten by the ttl value, i.e., UDT_SNDTIMEO has no effects to sendmsg.

Error Code Comment

2001

connection broken before send is completed.

2002

u is not connected.

5003

invalid parameters.

5004

u is an invalid UDT socket.

5009

cannot use sendmsg in SOCK_STREAM mode.

6001

insufficient buffer size for non-blocking sending.

Description

The sendmsg method sends an application message as a whole. The application can specify a time-to-live value for each individual message. The message will only be dilevered within the TTL; otherwise the message will be discarded. An negative value is equivalent to an infinite TTL.

Applications can also specify if the message should be delivered in order, which means that the message cannot be retrieved by the receiver before all messages prior to it are either successfully received or discarded.

In blocking mode, the sendmsg is blocked until there is enough buffer size in the UDT sender's buffer. On non-blocking mode, sendmsg will return immediately. Note that message will always be sent as a whole; no partial message will be sent if there is not enough buffer spaces.

See Also

select, send, recv, recvmsg, sendfile, recvfile, getoverlappedresult