getsockname()

get the name of a socket

Synopsis:

#include <sys/socket.h>

int getsockname( int s, 
                 struct sockaddr *name, 
                 int *namelen );

Description:

The getsockname() function returns the current name for the specified socket. The namelen parameter should indicate the amount of space pointed to by name. On return, namelen contains the actual size of the name (in bytes).

Returns:

0
Success.
-1
An error occurred; errno is set.

Errors:

If an error occurred, errno could contain one of the following:

EBADF
The argument s isn't a valid descriptor.
EFAULT
The name parameter points to memory that isn't in a valid part of the process address space.
ENOBUFS
Insufficient resources were available in the system to perform the operation.

Classification:

POSIX 1003.1g (draft)

Safety:
Interrupt handler No
Signal handler No
Thread Yes

See also:

getpeername()