UDT Reference: UDT Functions

bind

The bind method associates an socket with a local address.

int bind(
  UDTSOCKET u,

  const struct sockaddr *name,
  int namelen
);

Parameters

u
[in] Descriptor identifying an unbound socket.
name
[in] Address to assign to the socket from the sockaddr structure.
namelen
[in] Length of the value in the name parameter.

Return Values

If the binding is successful, bind returns 0, otherwise it returns UDT::ERROR and the specific error information can be retrieved using getlasterror.

Error Code Comment

5001

u has already been bound to a certain address.

5003

the address is either invalid or unavailable.

5004

u is an invalid UDT socket.

Description

The bind method is usually used to assign a UDT socket a local address, including the IP version, local IP address, and port number. This is not necessary in all cases, except that before a listen call, a socket must be bound.

If the bind method is not called by applications, the socket will be bound to any available address automatically when connect is called.

See Also

listen, connect, setsockopt, getsockopt