UDT Reference: CUDT Methods

getOpt

setOpt

The getOpt and setOpt methods read or set up UDT options respectively.

void getOpt(
   UDTOpt optName,

   const void* optval,

   const int& optlen);
);

 

void setOpt(
   UDTOpt optName,

   void* optval,

   int& optlen);
);

Parameters

optName
[in] The enum name of UDT option. The name and meaning are listed in the table below:
 
Name Meaning Comment

UDT_ADDR

Local IP address

string of IPv4 or IPv6 address, e.g., "127.0.0.1", or "::1".

UDT_PORT

Local port number

Default value is 0 (i.e., choose any available port).

UDT_PCH

If the given port number changeable

true: Yes; false: No. Default value is false.

UDT_MTU

MTU (Maximum Transfer Unit)

Default value is 1500 bytes.

UDT_SNDSYN

Blocking mode of the data sending

true: blocking sending; false: non-blocking sending. Default value is false.

UDT_RCVSYN

Blocking mode of the data receiving 

true: blocking receiving; false: non-blocking receiving. Default value is true.

UDT_MFLAG

How to deal with the buffer after it is sent

0: return to application; 1: automatically free it by UDT. Default value is 1.

UDT_RC

Rate control algorithm option

NOT supported in current version.

UDT_FC

Maximum flow window size

Default value is 25600.

UDT_BUF

UDT buffer size

Default value is 40960000 bytes.

UDT_USB

UDP sending buffer size

Default value is 65536 bytes.

UDT_URB

UDP receiving buffer size

Default value is 4194304 bytes.

UDT_IPV

IP version

4: IPv4; 6: IPv6. Default value is 4.

 
optval
[in] The pointer to the value of UDT option of optName.
optlen
[in (setOpt), out (getOpt)] The length of the optval.

Return Values

NONE.

A CUDTException exception can be threw out if one of the following situation satisfied:

    1. setOpt is called after the UDT has been connected.

    2. optval is not a meaningful value for the given optName.

    3. The optName is not supported in the current version.

Description

The setOpt method set the UDT option optName with the value of optval. The parameter of optlen is only useful for UDT_ADDR or UDT_MCADDR. It MUST be called before listen or connect methods, since the option value will be used to initialize the data structures in these two methods.

The getOpt method read the current option value. The value is written into the buffer pointed by optval, and the length is returned in optlen. The returned value may be meaningless if the method is called before open or setOpt. For example, the UDT_PORT value is 0 at that time.

UDT_FC is generally set as bandwidth * (RTT + 0.01) or greater.

Setting UDT_PORT or UDT_ADDR is equivalent to call open with the same parameters.

Examples

To set data sending in non-blocking mode, the codes can be like:

CUDT udt;

bool block = false;

udt.setOpt(UDT_SNDSYN, &block, sizeof(bool));

To explicitly assign an IPv4 address,

CUDT udt;

char* addr = "192.168.0.1";

udt.setOpt(UDT_ADDR, addr, strlen(addr));

See Also

listen, connect, open