getsockname
Purpose
Gets the socket name.
Library
Sockets Library (libsock.a)
Syntax
int getsockname (s, name, namelen)
int s;
struct sockaddr *name;
int *namelen;
Description
The getsockname subroutine stores the current name for
the socket specified by the s parameter into the struc-
ture pointed to by the name parameter. Initialize the
value pointed to by the namelen parameter to indicate the
amount of space pointed to by name. On return, the
namelen parameter points to the actual size of the name
returned (in bytes).
Return Value
Upon successful completion, a value of 0 is returned. If
the getsockname routine fails, a value of -1 is returned,
and errno is set to indicate the error.
Diagnostics
The subroutine fails if one or more of the following are
true:
EBADF The s parameter is not valid.
ENOTSOCK The s parameter refers to a file, not a
socket.
ENOBUFS Insufficient resources were available
in the system to complete the call.
EFAULT The addr parameter is not in a writable
part of the user address space.
Related Information
In this book: "bind" and "socket."