UDT Tutorial |
There are three ways to use UDT in your application. If you want to write a new application you can use the UDT API directly, which is similar to socket API. If you have already an application that uses certain network programming framework (e.g., XIO), you can write a UDT driver for that application. Finally, if your application does NOT use fork() with sockets, you can recompile your application by linking it with the UDT library (with -DCAPI compile option when compiling UDT) without any changes to your source code!
Below is a brief description on how to use UDT in a C++ program. UDT is a written in C++. Using UDT is almost the same as using regular socket API. That is, you can easily translate a network application that was using socket API into a new one using UDT API.
For example:
in socket, you write:
int s = socket(AF_INET, SOCK_STREAM, 0); |
its counterpart in UDT is:
UDTSOCKET u = UDT::socket(AF_INET, SOCK_STREAM, 0); |
UDT defines its own namespace UDT to differentiate the UDT APIs from the regular socket APIs. In the above example, a qualifier of UDT:: is 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., SOCK_DGRAM option, they are simply not available in UDT API.
UDT methods are thread safe. However, it does NOT support fork() operation and the manner after fork() is undefined.
Any applications using UDT should use the following header and one of the libraries, depending on the platform.
libudt.so
libudt.a
udt.dll
udt.lib
udt.dylib