PHP.nl

socket_getpeername

socket_getpeername

Queries the remote side of the given socket

bool **socket_getpeername** Socket $socket string $address int $port

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.

socket A instance created with or . Socket``socket_create``socket_accept

address If the given socket is of type or , will return the peers (remote) in appropriate notation (e.g. or ) in the parameter and, if the optional parameter is present, also the associated port. AF_INET``AF_INET6``socket_getpeernameIP address127.0.0.1``fe80::1``address``port

   If the given socket is of type ,
    will return the Unix filesystem
   path (e.g. ) in the
    parameter.
  `AF_UNIX``socket_getpeername``/var/run/daemon.sock``address`

port If given, this will hold the port associated to . address

return.success may also return false if the socket type is not any of , , or , in which case the last socket error code is updated. socket_getpeername``AF_INET``AF_INET6``AF_UNIXnot

Opmerking: > should not be used with sockets created with . Only sockets created with or a primary server socket following a call to will return meaningful values. socket_getpeername``AF_UNIX``socket_accept``socket_connect``socket_bind

Opmerking: > For having to return a meaningful value, the socket it is applied upon must of course be one for which the concept of "peer" makes sense. socket_getpeername

socket_getsockname``socket_last_error``socket_strerror