Skip to content

Add hability to query remote ADDR:PORT #4

@SirArthurPT

Description

@SirArthurPT

Here's a small change to SocketClient.php in order to make it able to query the remote address and port:

address = $address; $this->port = $port; $this->connection = $connection; socket_getpeername($connection, $remote_addr, $remote_port); $this->remote_addr = $remote_addr; $this->remote_port = $remote_port; } public function send( $message ) { socket_write($this->connection, $message, strlen($message)); } public function read($len = 1024) { if ( ( $buf = @socket_read( $this->connection, $len, PHP_BINARY_READ ) ) === false ) { return null; } return $buf; } public function getAddress() { return $this->address; } public function getRemoteAddress(){ return $this->remote_addr; } public function getPort() { return $this->port; } public function getRemotePort(){ return $this->remote_port; } public function close() { socket_shutdown( $this->connection ); socket_close( $this->connection ); } ``` }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions