Returns the name of the connected peer.
Format
#include <socket.h>
int getpeername (int s, struct sockaddr *name,
int *namelen);
Routine Variants
This socket routine has a variant named __bsd44_getpeername. Enabled
by defining _SOCKADDR_LEN, this variant implements 4.4BSD-compatible
semantics. See Section A.7 for
more information.
Arguments
- s
- A socket descriptor that has been created using socket.
- name
- A pointer to a buffer within which the peer name is to be
returned.
- namelen
- An address of an integer that specifies the size of the
name buffer. On return, it will be modified to reflect
the actual length, in bytes, of the name returned.
Description
This routine returns the name of the peer connected to the
socket descriptor specified.
See also bind, getsockname, and socket in this appendix.
Return Values
0 | Indicates success. |
-1 | Indicates an error; errno is set to one
of the following:
- EBADF - The descriptor is invalid.
- ENOTSOCK - The socket descriptor references a file, not a
socket.
- ENOTCONN - The socket is not connected.
- ENOBUFS - Resources were insufficient in the system to
perform the operation.
- EFAULT - The name parameter is not a valid part
of the user address space.
|
Previous Page | Next Page | Table of Contents | Index