[Previous] [Contents] [Index] [Next]

getpeername()

Get the name of the peer connected to a socket

Synopsis:

#include <sys/socket.h>

int getpeername( int s, 
                 struct sockaddr * name, 
                 size_t * namelen );

Library:

socket3r.lib, socket3s.lib

Description:

The getpeername() function returns the name of the peer connected to socket s. You should initialize the namelen parameter to indicate the amount of space pointed to by name. On return, namelen contains the actual size of the name (in bytes). The name is truncated if the buffer provided is too small.

Returns:

0
Success.
-1
An error occurred (errno is set).

Errors:

EBADF
Invalid descriptor s.
EFAULT
The name parameter points to memory not in a valid part of the process address space.
ENOBUFS
Insufficient resources were available in the system to perform the operation.
ENOTCONN
The socket isn't connected.

Classification:

Standard Unix, POSIX 1003.1g (draft)

Safety:
Interrupt handler No
Signal handler No
Thread No

See also:

accept(), bind(), getsockname(), socket()


[Previous] [Contents] [Index] [Next]