.\" Modified 17 Jul 2002, Michael Kerrisk <mtk.manpages@gmail.com>
.\" Added 'socket' to NAME, so that "man -k socket" will show this page.
.\"
-.TH GETPEERNAME 2 2015-08-08 "Linux" "Linux Programmer's Manual"
+.TH GETPEERNAME 2 2017-09-15 "Linux" "Linux Programmer's Manual"
.SH NAME
getpeername \- get name of connected peer socket
.SH SYNOPSIS
.B #include <sys/socket.h>
-.sp
+.PP
.BI "int getpeername(int " sockfd ", struct sockaddr *" addr \
", socklen_t *" addrlen );
.SH DESCRIPTION
.IR addr .
On return it contains the actual size of the name returned (in bytes).
The name is truncated if the buffer provided is too small.
-
+.PP
The returned address is truncated if the buffer provided is too small;
in this case,
.I addrlen
.B EBADF
The argument
.I sockfd
-is not a valid descriptor.
+is not a valid file descriptor.
.TP
.B EFAULT
The
The socket is not connected.
.TP
.B ENOTSOCK
-The argument
+The file descriptor
.I sockfd
-is a file, not a socket.
+does not refer to a socket.
.SH CONFORMING TO
POSIX.1-2001, POSIX.1-2008, SVr4, 4.4BSD
.RB ( getpeername ()
first appeared in 4.2BSD).
.SH NOTES
-The third argument of
-.BR getpeername ()
-is in reality an
-.I "int\ *"
-(and this is what 4.x BSD and libc4 and libc5 have).
-Some POSIX confusion resulted in the present
-.IR socklen_t ,
-also used by glibc.
-See also
+For background on the
+.I socklen_t
+type, see
.BR accept (2).
-
+.PP
For stream sockets, once a
.BR connect (2)
has been performed, either socket can call