UDT Reference: Functions

#### socket

The socket method creates a new UDT socket.

UDTSOCKET socket(
int af,
int type,
int protocol
);

##### Parameters

af
  [in] IP Family: AF_INET or AF_INET6.
type
  [in] Type of the socket: SOCK_STREAM or SOCK_DGRAM.
protocol
  [in] Ignored. For compatibility only.

##### Return Value

If no error occurs, socket returns the new UDT socket descriptor; otherwise, it returns UDT::INVALID_SOCK and the error information can be retrieved by getlasterror.

Error Name | Error Code | Comment
EINVPARAM | 5003 | Invalid parameters.

##### Description

The socket methods creates a new socket. The is no limits for the number of UDT sockets in one system, as long as there is enough system resource. UDT supports both IPv4 and IPv6, which can be selected by the af parameter. On the other hand, two socket types are supports in UDT, i.e., SOCK_STREAM for data streaming and SOCK_DGRAM for messaging. Note that UDT sockets are connection oriented in all cases.

##### See Also

close