UDT Tutorial

### Messaging with Partial Reliability

When a UDT socket is created as SOCK_DGRAM type, UDT will send and receive data as messages. The boundary of the message is preserved and the message is delivered as a whole unit. Sending or receving messages do not need a loop; a message will be either completely delivered or not delivered at all. However, at the receiver side, if the user buffer is shorter than the message length, only part of the message will be copied into the user buffer while the message will still be discarded.

Example: send and receive messages using UDT.

UDTSOCKET u = UDT::socket(AF_INET, SOCK_DGRAM, 0);
char data[1024];
int size = 1024;
int ssize = UDT::sendmsg(client, data, size, -1, false);
int rsize = UDT::recvmsg(u, data, size);

At the sender side, applications can specify two options for every message. The first is the life time (TTL) of a message. The default value is infinite, which means that the message will always be delivered. If the value is a postive one, UDT will discard the message if it cannot be delivered by the life time expires. The second is the order of the message. An in-order message means that this message will not be delivered unless all the messages prior to it are either delivered or discarded.

Synchronization modes (blocking vs. non-blocking) are also applied to SOCK_DGRAM sockets, so does not other UDT mechanisms including but limited to congestion control, flow control, and connection maintainence. Finally, note that UDT SOCK_DGRAM socket is also connection oriented. A UDT connection can only be set up between the same socket types.