UDT Reference: Functions

getsockname

The getsockname method retrieves the local address associated with a UDT socket.

int getsockname(
  UDTSOCKET u,
  struct sockaddr* name,
  int* namelen
);
Parameters
u
[in] Descriptor identifying a connected socket.
name
[out] The structure to store the local address.
addrlen
[in, out] pointer to the size of the name structure.
Return Value

On success, getlasterror returns 0 and the local address information is stored in name; otherwise it returns UDT::ERROR and the specific error information can be retrieved using getlasterror.

Error Name Error Code Comment
  EINVPARAM Invalid parameters.
EINVSOCK 5004 u is an invailid UDT socket.
EUNBOUNDSOCK 5005 u is not bound to a local address yet.
Description

The getsockname retrieves the local address associated with the socket. The UDT socket must be bound explicitly (via bind) or implicitly (via connect), otherwise this method will fail because there is no meaningful address bound to the socket.

See Also

listen, connect