PHP.nl

socket_getsockname

socket_getsockname

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

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

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_getsockname``AF_UNIX``socket_connect``socket_accept``socket_bind

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

address If the given socket is of type or , will return the local 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_getsocknameIP 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_getsockname``/var/run/daemon.sock``address`

portIf provided, this will hold the associated port.

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_getsockname``AF_INET``AF_INET6``AF_UNIXnot

socket_getpeername``socket_last_error``socket_strerror