Class SecureServer
The SecureServer class implements the
ServerInterface and is responsible for providing a secure TLS
(formerly known as SSL) server.
It does so by wrapping a Server instance which waits for
plaintext TCP/IP connections and then performs a TLS handshake for each
connection.
`php $server = new Server(8000, $loop); $server = new
SecureServer($server, $loop, array( // tls context options here… ));
`
Whenever a client completes the TLS handshake, it will emit a
connection event with a connection instance implementing
[ConnectionInterface](#connectioninterface):
`php $server->on('connection', function (ConnectionInterface
$connection) { echo 'Secure connection from' .
$connection->getRemoteAddress() . PHP_EOL;
$connection->write('hello there!' . PHP_EOL); … }); `
Whenever a client fails to perform a successful TLS handshake, it will emit
an error event and then close the underlying TCP/IP connection:
`php $server->on('error', function (Exception $e) { echo
'Error' . $e->getMessage() . PHP_EOL; }); `
See also the ServerInterface for more details.
Note that the SecureServer class is a concrete implementation
for TLS sockets. If you want to typehint in your higher-level protocol
implementation, you SHOULD use the generic ServerInterface
instead.
- Evenement\EventEmitter implements Evenement\EventEmitterInterface uses Evenement\EventEmitterTrait
-
React\Socket\SecureServer
implements
React\Socket\ServerInterface
Namespace: React\Socket
See:
React\Socket\ServerInterfaceSee:
React\Socket\ConnectionInterfaceLocated at SecureServer.php
public
|
#
__construct(
Creates a secure TLS server and starts waiting for incoming connections |
public
?string
|
|
public
|
|
public
|
|
public
|
emit(),
listeners(),
on(),
once(),
removeAllListeners(),
removeListener()
|
(),
(),
(),
(),
(),
()
|
$listeners
|