getsockname()

Get the name of a socket

Synopsis:

#include <sys/socket.h>

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

Arguments:

s
The file descriptor of the socket whose name you want to get.
name
A pointer to a sockaddr object where the function can store the socket's name.
namelen
A pointer to a socklen_t object that initially indicates the amount of space pointed to by name. The function updates namelen to contain the actual size of the name (in bytes).

Library:

libsocket

Use the -l socket option to qcc to link against this library.

Description:

The getsockname() function returns the current name for the specified socket.

Returns:

0
Success.
-1
An error occurred (errno is set).

Errors:

EBADF
Invalid descriptor s.
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.1

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler No
Thread Yes

See also:

getpeername()