UDT Tutorial

### Introduction to Programming with UDT

The prerequisite knowledge for using UDT is sound experience on C++ and socket programing. This is enough to use UDT in distributed applications. If you are familiar with computer networking, you may find UDT more powerful.

UDT is a C++ library, which has almost identical routines as the BSD socket APIs. Using UDT in a C++ program is very straightforward. In fact, you may easily modify your existing code from TCP to UDT.

Because of the similarity between UDT API and BSD socket API, UDT defines its own namespace UDT to differentiate the UDT APIs from the regular socket APIs. A qualifier of UDT:: should be put before the UDT socket call. UDTSOCKET is a data type to describe a UDT socket. For a complete UDT structures and constant definitions, please see Reference:UDT Structures. For a complete description of UDT socket APIs, please see Reference:UDT Functions.

For those socket APIs that does not involve with a socket descriptor, e.g., inet_pton, they are not wrapped by UDT API, and the applications should continue to use the original functions. For those socket APIs or options not appropriate to UDT, e.g., certain TCP options, they are simply not available in UDT API.

For example, using BSD socket, you write:

int s = socket(AF_INET, SOCK_STREAM, 0);

Its counterpart in UDT is like this:

UDTSOCKET u = UDT::socket(AF_INET, SOCK_STREAM, 0);

UDT API is thread-safe. UDT sockets can be shared by multiple threads and UDT API on the same socket can be made concurrently. However, because of its application level nature, UDT sockets cannot be shared among processes. That is, a UDT socket created in one process cannot be used in another process.

If you use a programming language other than C++, you may need to write certain wrapper for the UDT C++ API. For example, you may use "extern C" to wrap UDT API in C; there are also ways to call C++ API in Java.

To use UDT in a C++ application:

Header

#include <udt.h>

Library (depending on platforms)

libudt.so
libudt.a
udt.dll
udt.lib
udt.dylib

Namespace

UDT