GETPEERNAME(2) BSD System Calls Manual GETPEERNAME(2)NAME
getpeername -- get name of connected peer
Standard C Library (libc, -lc)
getpeername(int s, struct sockaddr * restrict name, socklen_t * restrict namelen);
The getpeername() system call returns the name of the peer connected to socket s. The namelen argument should be initialized to indicate the
amount of space pointed to by name. On return it contains the actual size of the name returned (in bytes). The name is truncated if the
buffer provided is too small.
The getpeername() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to
indicate the error.
The call succeeds unless:
[EBADF] The argument s is not a valid descriptor.
[ECONNRESET] The connection has been reset by the peer.
[EINVAL] The value of the namelen argument is not valid.
[ENOTSOCK] The argument s is a file, not a socket.
[ENOTCONN] The socket is not connected.
[ENOBUFS] Insufficient resources were available in the system to perform the operation.
[EFAULT] The name argument points to memory not in a valid part of the process address space.
SEE ALSO accept(2), bind(2), getsockname(2), socket(2)HISTORY
The getpeername() system call appeared in 4.2BSD.
BSD June 4, 1993 BSD
Check Out this Related Man Page
GETPEERNAME(2) Linux Programmer's Manual GETPEERNAME(2)NAME
getpeername - get name of connected peer socket
int getpeername(int s, struct sockaddr *name, socklen_t *namelen);
Getpeername returns the name of the peer connected to socket s. The namelen parameter should be initialized to indicate the amount of
space pointed to by name. On return it contains the actual size of the name returned (in bytes). The name is truncated if the buffer pro-
vided is too small.
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.
EBADF The argument s is not a valid descriptor.
The argument s is a file, not a socket.
The socket is not connected.
Insufficient resources were available in the system to perform the operation.
EFAULT The name parameter points to memory not in a valid part of the process address space.
SVr4, 4.4BSD (the getpeername function call first appeared in 4.2BSD).
The third argument of getpeername is in reality an `int *' (and this is what BSD 4.* and libc4 and libc5 have). Some POSIX confusion
resulted in the present socklen_t. The draft standard has not been adopted yet, but glibc2 already follows it and also has socklen_t. See
SEE ALSO accept(2), bind(2), getsockname(2)BSD Man Page 1993-07-30 GETPEERNAME(2)
hi every one
my post is about socket programming
i would know if anyone knows about send binary file in peer to peer connection.
if you have any information about it plzzz contact me or reply my post
SpY974 (2 Replies)
hello socket programming expert,
I having difficulties in understanding how select() function in socket programming work.... I'm trying to create my own peer-to-peer chat or file transfer program by using the select() function.... Therefore does anyone had any tutorial or source code that... (4 Replies)
My socket program is to communicate between the two systems connected with lan. Always i am getting an error saying bind value is -1 or not connected. ..If i run both the server and client programs in the same machine in two diff terminals they are working but they are not working between two... (3 Replies)
I am getting the following error in /var/adm/messages. Can any one help me out on this?
ZXXXXXA:/# tail /var/adm/messages
Oct 26 00:13:04 ZXXXXXA ftpd: setsockopt SO_KEEPALIVE Invalid argument
Oct 26 00:13:04 ZXXXXXA ftpd: setsockopt (SO_OOBINLINE): Invalid argument
Oct 26... (3 Replies)