getsockname()

get socket name 

Function


SYNOPSIS

#include <sys/socket.h>

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


DESCRIPTION

The getsockname() 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. When returned, namelen contains the actual size (in bytes) of the name returned.


PARAMETERS

s 

Is the integer descriptor of the desired socket.

name 

Points to a sockaddr structure containing the socket address.

namelen 

Points to an integer that states the address length in bytes.


RETURN VALUES

If successful, getsockname() returns a zero. If failure occurs, it returns a value of -1 and sets errno to one of the following values:

EBADF 

The parameter s is not a valid descriptor.

ENOTSOCK 

The parameter s is not a socket.

EFAULT 

name or namelen is an invalid pointer.

EINVAL 

The socket has not been bound.


CONFORMANCE

UNIX 98.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
bind(), socket()


PTC MKS Toolkit 10.4 Documentation Build 39.