UDT Reference: UDT Functions

close

The close method closes the UDT entity.

int close(

   UDTSOCKET u

);

Parameters

u
[in] Descriptor identifying the socket to close.

Return Values

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

Error Code Comment

5004

u is an invalid UDT socket.

6001

u is non-blocking (UDT_SNDSYN = false) but UDT_LINGER option is set to be non-zero.

Description

The close method shutdowns the connection and releases all protocol data structures. On a blocking socket, if UDT_LINGER is non-zero, the close call will wait until all data in the sending buffer are sent out or the waiting time has exceeded the expiration time set by UDT_LINGER. On a non-blocking socket, close will return immediately.

The closing UDT entity will send a close request to its peer side (if a connection exists on the socket) so that the peer side will also close. However, this close information is best-effort, i.e., if the close request packet is lost, the peer side will not know the connection close until a time-out event.

All sockets should be closed if they are not used any more.

See Also

socket