Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

bind(2)

socket(2)

getpeername(2)

inet(7F)

af_ccitt(7F)

getsockname(2)

NAME

getsockname − get socket address

SYNOPSIS

#include <sys/socket.h>

AF_CCITT only:

#include <x25/x25addrstr.h>

int getsockname(int s, void ∗addr, int ∗addrlen);

DESCRIPTION

getsockname() returns the address of the socket indicated by s, where s is a socket descriptor.  addr points to a socket address structure in which this address is returned.  addrlen points to an int which should be initialized to indicate the size of the address structure.  On return it contains the actual size of the address returned (in bytes).  If addr does not point to enough space to contain the whole address of the socket, only the first addrlen bytes of the address are returned. 

AF_CCITT only:

The x25_host[] field of the addr struct returns the X.25 addressing information of the local socket s. The x25ifname[] field of the addr struct contains the name of the local X.25 interface through which the call arrived. 

RETURN VALUE

Upon successful completion, getsockname() returns 0; otherwise, it returns −1 and sets errno to indicate the error. 

ERRORS

getsockname() fails if any of the following conditions are encountered:

[EBADF] s is not a valid descriptor. 

[ENOTSOCK] s is a file, not a socket. 

[ENOBUFS] Insufficient resources were available in the system to perform the operation. 

[EFAULT] The addr or addrlen parameters are not valid pointers. 

[EINVAL] The socket has been shut down. 

[EOPNOTSUPP] Operation not supported for AF_UNIX sockets. 

AUTHOR

getsockname() was developed by the University of California, Berkeley. 

SEE ALSO

bind(2), socket(2), getpeername(2), inet(7F), af_ccitt(7F). 

Hewlett-Packard Company  —  HP-UX Release 9.03: April 1994

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026