php man page for socket_getpeername

Query: socket_getpeername

OS: php

Section: 3

Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar

SOCKET_GETPEERNAME(3)							 1						     SOCKET_GETPEERNAME(3)

socket_getpeername  -  Queries the remote side of the given socket which may either result in host/port or in a Unix filesystem path, dependent on
its type

SYNOPSIS
bool socket_getpeername (resource $socket, string &$address, [int &$port])
DESCRIPTION
Queries the remote side of the given socket which may either result in host/port or in a Unix filesystem path, dependent on its type.
PARAMETERS
o $socket - A valid socket resource created with socket_create(3) or socket_accept(3). o $address - If the given socket is of type AF_INET or AF_INET6, socket_getpeername(3) will return the peers (remote) IP address in appropri- ate notation (e.g. 127.0.0.1 or fe80::1) in the $address parameter and, if the optional $port parameter is present, also the associated port. If the given socket is of type AF_UNIX, socket_getpeername(3) will return the Unix filesystem path (e.g. /var/run/daemon.sock) in the $address parameter. o $port - If given, this will hold the port associated to $address.
RETURN VALUES
Returns TRUE on success or FALSE on failure. socket_getpeername(3) may also return FALSE if the socket type is not any of AF_INET, AF_INET6, or AF_UNIX, in which case the last socket error code is not updated.
NOTES
Note socket_getpeername(3) should not be used with AF_UNIX sockets created with socket_accept(3). Only sockets created with socket_con- nect(3) or a primary server socket following a call to socket_bind(3) will return meaningful values. Note For having socket_getpeername(3) to return a meaningful value, the socket it is applied upon must of course be one for which the concept of "peer" makes sense.
SEE ALSO
socket_getsockname(3), socket_last_error(3), socket_strerror(3). PHP Documentation Group SOCKET_GETPEERNAME(3)
Related Man Pages
sd_is_mq(3) - debian
sd_is_fifo(3) - debian
socket_recv(3) - php
socket_create_pair(3) - php
stream_socket_server(3) - php
Similar Topics in the Unix Linux Community
Set-up a mirrordisk
[Problem]Reuse port in BSD socket
open a socket
permission to bind a socket to port 843?
AIX full path to socket library