UDT Reference

UDT Reference: Functions

#### close

The close method closes a UDT connection.

int close(
UDTSOCKET u
);

##### Parameters

u
  [in] Descriptor identifying the socket to close.

##### Return Value

If success, 0 is returned; otherwise, UDT::ERROR is returned and specific error information can be retrieved by getlasterror.

Error Name | Error Code | Comment
EINVSOCK | 5004 | u is an invalid UDT socket.

##### Description

The close method gracefully shutdowns the UDT connection and releases all related data structures associated with the UDT socket. If there is no connection associated with the socket, close simply release the socket resources.

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. However, if UDT_SYNSND is set to false (i.e., non-blocking sending), close will return immediately and any linger data will be sent at background until the linger timer expires.

The closing UDT socket will send a shutdown message to the peer side so that the peer socket will also be closed. This is a best-effort message. If the message is not successfully delivered, the peer side will also be closed after a time-out. In UDT, shutdown is not supported.

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

##### See Also

socket, setsockopt