The bind method binds a UDT socket to a known or an available local address.
If the binding is successful, bind returns 0, otherwise it returns UDT::ERROR and the specific error information can be retrieved using getlasterror.
Error Name | Error Code | Comment |
EBOUNDSOCK | 5001 | u has already been bound to certain address. |
EINVPARAM | 5003 | the address is either invalid or unavailable. |
EINVSOCK | 5004 | u is an invalid UDT socket. |
The bind method is usually to assign a UDT socket a local address, including IP address and port number. If INADDR_ANY is used, a proper IP address will be used once the UDT connection is set up. If 0 is used for the port, a randomly available port number will be used. The method getsockname can be used to retrieve this port number.
The bind call is necessary in all cases except for a socket to listen. If bind is not called, UDT will automatically bind a socket to a randomly available address when a connection is set up.
By default, UDT will reuse existing UDP port for new UDT sockets, unless UDT_REUSEADDR is set to false. When UDT_REUSEADDR is false, UDT will create an exclusive UDP port for this UDT socket. UDT_REUSEADDR must be called before bind.
listen, connect, setsockopt, getsockopt