GETSOCKNAME [ Berkeley Sockets/iX Reference Manual ] MPE/iX 5.0 Documentation
Berkeley Sockets/iX Reference Manual
GETSOCKNAME
C Interface
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
getsockname(s, addr, addrlen)
int s;
struct sockaddr_in *addr;
int *addrlen;
Description
The argument s is a socket descriptor. The getsockname system call
returns the address of the socket indicated by s. The addr parameter
points to a socket address structure in which this address is returned.
The addrlen parameter points to an int parameter that should be
initialized to indicate the size of the address structure. On return,
the addrlen parameter 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.
This call is supported for AF_INET only.
Return Value
If the call is successful, a 0 is returned. If the call fails, a -1 is
returned, and the error code is stored in errno.
Errors
The following errors are returned by getsockname:
[EBADF] The argument s is not a valid descriptor.
[ENOTSOCK] The argument 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] The operation is not supported for AF_UNIX sockets.
Author
UCB (University of California at Berkeley)
See Also
bind, socket, getpeername
MPE/iX 5.0 Documentation