Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

getpeername(2) [hpux man page]

getpeername(2)							System Calls Manual						    getpeername(2)

NAME
getpeername - get address of connected peer SYNOPSIS
AF_CCITT Only UNIX 03 Only (X/Open Sockets) Obsolescent UNIX 95 Only (X/Open Sockets) DESCRIPTION
returns the address of the peer socket connected to the socket indicated by s, where s is a socket descriptor. addr points to a socket address structure in which this address is returned. addrlen points to a variable that should be initialized to indicate the size of the address structure. On return, the variable contains the actual size of the address returned (in bytes). If addr does not point to enough space to contain the whole address of the peer, only the first addrlen bytes of the address are returned. AF_CCITT Only The addr struct contains the X.25 addressing information of the remote peer socket connected to socket s. However, the field of the addr struct contains the name of the local X.25 interface through which the call arrived. X/Open Sockets Compilation Environment See xopen_networking(7). RETURN VALUE
Upon successful completion, returns 0; otherwise it returns -1 and sets to indicate the error. ERRORS
fails if any of the following conditions are encountered: s is not a valid file descriptor. s is a valid file descriptor, but it is not a socket. The socket is not connected. No buffer space is available to perform the operation. addr or addrlen are not valid pointers. The socket has been shut down. The operation was interrupted by a signal. Application needs to retry the operation to get the address of peer socket. Not all possible values are documented in this manpage due to dependencies from the underlying protocol modules. OBSOLESCENCE
Currently, the and types are the same size. This is compatible with the UNIX 95 and UNIX 03 profiles. However, in a future release, might be a different size. In that case, passing a pointer will evoke compile-time warnings, which must be corrected in order for the applica- tion to behave correctly. Applications that use now, where appropriate, will avoid such migration problems. On the other hand, applica- tions that need to be portable to the UNIX 95 profile should follow the X/Open specification (see xopen_networking(7)). WARNINGS
Linking binary objects compiled to specification and binary objects compiled to specification to the same executable may result in unex- pected behavior, including application abnormal termination and unexpected socket errors. See xopen_networking(7) for details and remedy. FUTURE DIRECTION
Currently, the default behavior is the however, it might be changed to in a future release. At that time, any behavior that is incompati- ble with might be obsoleted. Applications that conform to the X/Open specification now will avoid migration problems (see xopen_network- ing(7)). AUTHOR
was developed by HP and the University of California, Berkeley. SEE ALSO
bind(2), socket(2), getsockname(2), thread_safety(5), inet(7F), xopen_networking(7). STANDARDS CONFORMANCE
getpeername(2)

Check Out this Related Man Page

GETPEERNAME(2)						     Linux Programmer's Manual						    GETPEERNAME(2)

NAME
getpeername - get name of connected peer socket SYNOPSIS
#include <sys/socket.h> int getpeername(int sockfd, struct sockaddr *addr, socklen_t *addrlen); DESCRIPTION
getpeername() returns the address of the peer connected to the socket sockfd, in the buffer pointed to by addr. The addrlen argument should be initialized to indicate the amount of space pointed to by addr. 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 returned address is truncated if the buffer provided is too small; in this case, addrlen will return a value greater than was supplied to the call. RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately. ERRORS
EBADF The argument sockfd is not a valid descriptor. EFAULT The addr argument points to memory not in a valid part of the process address space. EINVAL addrlen is invalid (e.g., is negative). ENOBUFS Insufficient resources were available in the system to perform the operation. ENOTCONN The socket is not connected. ENOTSOCK The argument sockfd is a file, not a socket. CONFORMING TO
SVr4, 4.4BSD (the getpeername() function call first appeared in 4.2BSD), POSIX.1-2001. NOTES
The third argument of getpeername() is in reality an int * (and this is what 4.x BSD and libc4 and libc5 have). Some POSIX confusion resulted in the present socklen_t, also used by glibc. See also accept(2). SEE ALSO
accept(2), bind(2), getsockname(2), ip(7), socket(7), unix(7) COLOPHON
This page is part of release 3.44 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2008-12-03 GETPEERNAME(2)
Man Page