UDT Reference: UDT Functions

getsockname

The getsockname function retrieves the local address associated to a socket.

int getsockname(
  UDTSOCKET u,

  struct sockaddr *name,

  int *namelen

);

Parameters

u
[in] Descriptor identifying a connected socket.
name
[out] The structure that receives the name of the peer.
namelen
[in, out] Pointer to the size of the name structure.

Return Values

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

Error Code Comment

5003

invalid parameters.

5004

u is an invalid UDT socket.

5005

u is not bound or connected yet.

Description

The getsockname method retrieves the local address associated to the socket. Before the socket is associated with any address (through bind or connect), this method will fail because there is no meaningful address bound to the socket.

See Also

bind, connect