@comment The start of a comment is indicated by the following comment. This @comment syntax is used by the script functxh.sh: @comment function @comment function getsockname @node getsockname, socket @findex getsockname @subheading Syntax @example #include int getsockname (int s, struct sockaddr *name, size_t *namelen); @end example @subheading Description @code{getsockname()} returns the local name of the socket @var{s}. @var{namelen} should be set to the size of the space pointed to by @var{name}. On completion @var{namelen} will contain the length of the address returned. If the buffer is too small, the address is truncated to fit. @code{getpeername()} returns the peer name for the socket (@pxref{getpeername}). @subheading Return Value On successful completion the function returns 0. Otherwise, a value of -1 is returned and @var{errno} is set appropriately. @table @samp @item EBADF @var{s} is not a valid file descriptor. @item ENOTSOCK @var{s} is not a socket. @item ENOBUFS There were not enough resources to complete this operation. @item EFAULT @var{name} could not be accessed. @end table @subheading Portability @portability posix, unix98 @subheading Example @example @end example