PHP stream_socket_get_name() Function
The PHP stream_socket_get_name() function returns the local or remote name of a given socket connection.
Syntax
stream_socket_get_name(handle, want_peer)
Parameters
handle |
Required. Specify the socket to get the name of. |
want_peer |
Required. If set to true the remote socket name will be returned, if set to false the local socket name will be returned. |
Return Value
Returns the name of the socket.
Example: stream_socket_get_name() example
The example below shows the usage of stream_socket_get_name() function.
<?php $socket = stream_socket_server("tcp://0.0.0.0:8000"); echo stream_socket_get_name($socket, false); ?>
The output of the above code will be:
0.0.0.0:8000
❮ PHP Streams Reference