Join 4,000+ others and never miss out on new tips, tutorials, and more.
4.x is outdated, please check the latest version 22.x
pecl install openswoole-22.0.0
Returns an array of a connected peer, showing its host and port that is being used by the socket.
Obtain the IP address and port of the opposite socket.
Only supported when the client type is:
This function can be used to obtain a UDP peer IP and port, after calling
$client->recv(). Because a client sends data to the server, a response may not be given, so this method can be used when needing to know the peer IP and port.
<?php var_dump($client->getPeerName()); ... // Output [ 'host' => '127.0.0.1', 'port' => 53653, ]