Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

getpeername(2) [mojave 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

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

10 More Discussions You Might Find Interesting

1. Programming

advanced socket programming

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 thx SpY974 (2 Replies)
Discussion started by: SpY974
2 Replies

2. IP Networking

socket address

Could anyone tell me please: -what the socket number of a network computer is? -How it is related to the IP address? -And how can I obtain this information from my work station? :D (2 Replies)
Discussion started by: fishman2001
2 Replies

3. 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

4. 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

5. UNIX for Dummies Questions & Answers

fatal: Read from socket failed: Connection reset by peer

I get this error when I log in through console: "fatal: Read from socket failed: Connection reset by peer". Can you tell me what this is and why it happens, and how to stop it? Thank you. (1 Reply)
Discussion started by: iamnew2solaris
1 Replies

6. IP Networking

The third argument of bind()

int bind(int socket, const struct sockaddr *address, socklen_t address_len); Man page says it specifies the length of the sockaddr structure pointed to by the address argument. But why bind() can't figure out the length itself, since the first member (eg:AF_INET or... (4 Replies)
Discussion started by: vistastar
4 Replies

7. 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

8. Shell Programming and Scripting

How to timeout and proceed in perl?

I'm writing a small socket program (UDP) to communicate between two servers. Problem is, I dont know how to implement time out hence my script keeps on waiting for the peer response. #!/usr/bin/bash use IO::Socket::INET; $|=1; $socket=new IO::Socket::INET->new(LocalPort=>5001, ... (2 Replies)
Discussion started by: Arun_Linux
2 Replies

9. Solaris

getpeername: Transport endpoint is not connected

Hi Folks, 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)
Discussion started by: vivek.goel.piet
3 Replies

10. Programming

Getting error address already in use in socket programming

Hi , I am getting error in bind function of "Address already in use" even also i have used the setsockopt function in that case . Please help int ret = 0; int listenSock = 0; struct sockaddr_in myAddr; struct sockaddr_in ... (1 Reply)
Discussion started by: vipin auja
1 Replies