UDT Reference: UDT Functions

getsockopt

setsockopt

The getsockopt and setsockopt methods read and set up UDT options, respectively.

int getsockopt(

  UDTSOCKET u,

  int level,

  SOCKOPT optname,

  char *optval,

  int *optlen

);

 

int setsockopt(

  UDTSOCKET u,

  int level,

  SOCKOPT optname,

  const char *optval,

  int optlen

);

Parameters

u
[in] Descriptor identifying an listening socket.
level
[in] Ignored. For compatibility use only.
optName
[in] The enum name of UDT option. The names and meanings are listed in the table below:
 
Name Type Meaning Comment

UDT_MSS

int

maximum packet size (bytes)

default value is 1500.

UDT_SNDSYN

bool

Blocking mode of the data sending

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

UDT_RCVSYN

bool

Blocking mode of the data receiving 

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

UDT_CC

CCCFactory*

CCC**

Congestion control algorithm option

optval is a pointer to a CCC Factory class. (for setsockopt)

optval is a pointer of pointer to a CCC class instance. (for getsockopt)

UDT_FC

int

Maximum flow window size

Default value is 25600.

UDT_SNDBUF

int

UDT sending buffer size limit

Default value is 40960000 bytes.

UDT_RCVBUF

int

UDT receiving buffer size limit

Default value is 40960000 bytes.

UDP_SNDBUF

int

UDP sending buffer size

Default value is 65536 bytes.

UDP_RCVBUF

int

UDP receiving buffer size

Default value is 4194304 bytes.

UDT_LINGER

linger

Linger time on close

Default value is 1 second linger time.

UDT_RENDEZVOUS bool Use rendezvous connection setup method Default value is false (no rendezvous setup).
UDT_SNDTIMEO int sending timeout value Default value is -1 (infinite timeout).
UDT_RCVTIMEO int receiving timeout value Default value is -1 (infinite timeout).
 
optval
[in (set), out (get)] The pointer to the value of UDT option of optName.
optlen
[in (set), in/out (get)] The length of the optval.

Return Values

On success, 0 is returned; Otherwise, UDT::ERROR is returned and the specific error information can be retrieved by getlasterror.

Error Code Comment

5001

the specific option cannot be set on a bound socket.

5002

the specific option cannot be set on a connected socket.

5003

the option value or option value length is invalid for setsockopt.

5004

u is an invalid UDT socket.

Description

The setsockopt method sets the UDT option optName with the value of optval. The parameter of optlen is checked to verify the goodness of the option value. Not all options can be set at any state of UDT.

UDT_MSS can only be set before bind; UDT_CC and UDT_FC can only be set before the listen or connect call.

The getsockopt method reads the current option value. The value is written into the buffer pointed by optval and the length is returned in optlen.

Examples

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

UDTSOCKET u;

...

bool block = false;

UDT::setsockopt(u, 0, UDT_SNDSYN, &block, sizeof(bool));

See Also

Configure UDT Options