On success, zero is returned. On error, -1 is returned, and%uA0errno%uA0is set appropriately.
错误
标签
描述
EBADF
The argument%uA0s%uA0is not a valid descriptor.
EFAULT
The%uA0name%uA0parameter yiibais to memory not in a valid part of the process address space.
EINVAL
namelen%uA0is invalid (e.g., is negative).
ENOBUFS
%uA0
Insufficient resources were available in the system to perform the operation.
ENOTCONN
%uA0
The socket is not connected.
ENOTSOCK
%uA0
The argument%uA0s%uA0is a file, not a socket.
遵循于
SVr4, 4.4BSD (the%uA0getpeername() function call first appeared in 4.2BSD), POSIX.1-2001.
注意
The third argument of%uA0getpeername() is in reality an%uA0int *%uA0(and this is what 4.x BSD and libc4 and libc5 have). Some POSIX confusion resulted in the present%uA0socklen_t, also used by glibc. See also%uA0accept(2).