Interface ConnectionInterface
Any incoming and outgoing connection is represented by this interface, such as a normal TCP/IP connection.
An incoming or outgoing connection is a duplex stream (both readable and
writable) that implements React's [DuplexStreamInterface](https://github.com/reactphp/stream#duplexstreaminterface).
It contains additional properties for the local and remote address (client IP)
where this connection has been established to/from.
Most commonly, instances implementing this ConnectionInterface
are emitted by all classes implementing the
[ServerInterface](#serverinterface) and used by all classes
implementing the [ConnectorInterface](#connectorinterface).
Because the ConnectionInterface implements the underlying
[DuplexStreamInterface](https://github.com/reactphp/stream#duplexstreaminterface)
you can use any of its events and methods as usual:
`php $connection->on('data', function ($chunk) { echo $chunk;
});
$connection->on('end', function () { echo 'ended'; });
$connection->on('error', function (Exception $e) { echo 'error: ' . $e->getMessage(); });
$connection->on('close', function () { echo 'closed'; });
$connection->write($data); $connection->end($data = null);
$connection->close(); // … `
For more details, see the [DuplexStreamInterface](https://github.com/reactphp/stream#duplexstreaminterface).
- React\Socket\ConnectionInterface implements React\Stream\DuplexStreamInterface
See:
React\Stream\DuplexStreamInterfaceSee:
React\Socket\ServerInterfaceSee:
React\Socket\ConnectorInterfaceLocated at ConnectionInterface.php
public
?string
|
#
getRemoteAddress( )
Returns the remote address (client IP and port) where this connection has been established with |
public
?string
|
#
getLocalAddress( )
Returns the full local address (client IP and port) where this connection has been established with |
close(),
end(),
isWritable(),
write()
|
emit(),
listeners(),
on(),
once(),
removeAllListeners(),
removeListener()
|
isReadable(),
pause(),
pipe(),
resume()
|