Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

getpeername(2) [bsd man page]

GETPEERNAME(2)							System Calls Manual						    GETPEERNAME(2)

NAME
getpeername - get name of connected peer SYNOPSIS
getpeername(s, name, namelen) int s; struct sockaddr *name; int *namelen; DESCRIPTION
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. DIAGNOSTICS
A 0 is returned if the call succeeds, -1 if it fails. ERRORS
The call succeeds unless: [EBADF] The argument s is not a valid descriptor. [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 parameter points to memory not in a valid part of the process address space. SEE ALSO
accept(2), bind(2), socket(2), getsockname(2) 4.2 Berkeley Distribution May 13, 1986 GETPEERNAME(2)

Check Out this Related Man Page

GETPEERNAME(2)						      BSD System Calls Manual						    GETPEERNAME(2)

NAME
getpeername -- get address of connected peer SYNOPSIS
#include <sys/socket.h> int getpeername(int socket, struct sockaddr *restrict address, socklen_t *restrict address_len); DESCRIPTION
The getpeername() function returns the address of the peer connected to the specified socket. The address_len parameter should be initialized to indicate the amount of space pointed to by address. On return it contains the actual size of the address returned (in bytes). The address is truncated if the buffer provided is too small. RETURN VALUES
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. ERRORS
The call succeeds unless: [EBADF] The argument socket is not a valid descriptor. [EFAULT] The address parameter points to memory not in a valid part of the process address space. [EINVAL] socket has been shut down. [ENOBUFS] Insufficient resources were available in the system to perform the operation. [ENOTCONN] Either the socket is not connected or it has not had the peer pre-specified. [ENOTSOCK] The argument socket refers to something other than a socket (e.g., a file). [EOPNOTSUPP] getpeername() is not supported for the protocol in use by socket. SEE ALSO
accept(2), bind(2), getsockname(2), socket(2) HISTORY
The getpeername() function call appeared in 4.2BSD. 4.2 Berkeley Distribution June 4, 1993 4.2 Berkeley Distribution
Man Page

4 More Discussions You Might Find Interesting

1. Programming

how to clear/clean mbufs (network buffer space)?

When I worked with client-server (socket) programming, I encountered "the socket error# 10055" which means "No buffer space available". This might be a symptom of one or more applications that didn't return system resources (like memory) properly. Temporary solution was to reboot the machine to... (7 Replies)
Discussion started by: dipti
7 Replies

2. AIX

p550 connected to a HMC

Morning, I've installed a new p550 into a rack and connected it up to the HMC but the HMC cannot find it, I don't understand why it's not? Has anyone else had this problem before? Thanks Kees (4 Replies)
Discussion started by: KeesH
4 Replies

3. Programming

Anyone know how to use socket select() function?

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)
Discussion started by: draggy
4 Replies

4. IP Networking

Execution Problem with socket

Hi 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)
Discussion started by: Gurvareddy
3 Replies