Middleware, development tools, realtime operating system
software and services for superior embedded design


Home
QNX Community Resources
Developer Support
QNX Documentation Library
QNX Developer Support

QNX Developer Support

QNX Software Systems
Developer Resources
Blogs
Board support packages
Foundry27 projects
Forums
Hardware support listing
Online video tutorials
Product documentation
Technical Articles

[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,
                 socklen_t * namelen );

Arguments:

s
The socket whose connected peer you want to get.
name
A buffer where the function can store the name of the peer.
namelen
A pointer to a socklen_t object that initially specifies the size of the buffer. This function stores the actual size of the name, in bytes, in this object.

Library:

libsocket

Use the -l socket option to qcc to link against this library.

Description:

The getpeername() function returns the name of the peer connected to socket s. 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:

POSIX 1003.1

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler No
Thread Yes

See also:

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


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