diff --git a/sock/SocketClient.php b/sock/SocketClient.php index 22491d4..65c053d 100644 --- a/sock/SocketClient.php +++ b/sock/SocketClient.php @@ -7,6 +7,9 @@ class SocketClient { private $connection; private $address; private $port; + + private $peer_address; + private $peer_port; public function __construct( $connection ) { $address = ''; @@ -15,6 +18,10 @@ public function __construct( $connection ) { $this->address = $address; $this->port = $port; $this->connection = $connection; + + socket_getpeername($connection, $address, $port); + $this->peer_address =$address; + $this->peer_port =$port; } public function send( $message ) { @@ -37,8 +44,16 @@ public function getPort() { return $this->port; } + public function getPeerAddress() { + return $this->peer_address; + } + + public function getPeerPort() { + return $this->peer_port; + } + public function close() { socket_shutdown( $this->connection ); socket_close( $this->connection ); } -} +}