1 GETPEERNAME(3C)          Standard C Library Functions          GETPEERNAME(3C)
   2 
   3 NAME
   4      getpeername - get name of connected peer
   5 
   6 LIBRARY
   7      Standard C Library (libc, -lc)
   8 
   9 SYNOPSIS
  10      #include <sys/types.h>
  11      #include <sys/socket.h>
  12 
  13      int
  14      getpeername(int s, struct sockaddr *restrict name, socklen_t *namelen);
  15 
  16 DESCRIPTION
  17      getpeername() returns the name of the peer connected to socket s.  The
  18      int pointed to by the namelen parameter should be initialized to indicate
  19      the amount of space pointed to by name.  On return it contains the actual
  20      size of the name returned (in bytes), prior to any truncation.  The name
  21      is truncated if the buffer provided is too small.
  22 
  23 RETURN VALUES
  24      If successful, getpeername() returns 0; otherwise it returns -1 and sets
  25      errno to indicate the error.
  26 
  27 ERRORS
  28      The call succeeds unless:
  29 
  30      [EBADF]            The argument s is not a valid descriptor.
  31 
  32      [ENOMEM]           There was insufficient user memory for the operation
  33                         to complete.
  34 
  35      [ENOSR]            There were insufficient STREAMS resources available
  36                         for the operation to complete.
  37 
  38      [ENOTCONN]         The socket is not connected.
  39 
  40      [ENOTSOCK]         The argument s is not a socket.
  41 
  42 MT-LEVEL
  43      Safe
  44 
  45 SEE ALSO
  46      accept(3C), bind(3C), getsockname(3C), sockaddr(3C), socket(3C),
  47      socket.h(3HEAD), attributes(5)
  48 
  49 illumos                         August 2, 2018                         illumos