getsockname()

NAME

getsockname() - get socket name

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUES

If the call succeeds, it returns 0. If it fails, it returns -1 and sets errno to indicate the error.

ERRORS

The call succeeds unless:

[EBADF]
The argument s is not a valid descriptor.
[EFAULT]
The name parameter points to memory not in a valid part of the process address space.
[EINVAL]
The socket s has not been bound. The call to bind(2) must succeed before getsockname(2) can be called successfully.
[ENOTSOCK]
The argument s is a file, not a socket.
[ENOBUFS]
Insufficient resources were available in the system to perform the operation.
[EOPNOTSUP]
The operation was not supported on this socket type.

SEE ALSO

bind(2)

socket(2)