Jump to content

Different ways to implement tls sockets using reactphp


Recommended Posts

What is the difference between the two blocks of code (other than one listens to all IPs on port 8000 while the other listens ton only 127.0.0.1 on port 8000)?
$server = new TcpServer(8000, $loop);
$server = new SecureServer($server, $loop, array(
    'local_cert' => 'server.pem',
    'passphrase' => 'secret'
));
$server = new Server('tls://127.0.0.1:8000', $loop, array(
    'tls' => array(
        'local_cert' => 'server.pem',
        'passphrase' => 'secret'
    )
));

Reference: https://github.com/reactphp/socket

 

Link to comment
Share on other sites

Or the difference between these two.  Not about tls, but related as it appears to do the same thing.

$connector = new React\Socket\Connector($loop, ['timeout' => 10.0]);
$connector->connect('127.0.0.1:8080')->then(function (ConnectionInterface $conn) use ($loop) {/* bla bla */});
$connector = new React\Socket\Connector($loop);
$timeoutConnector = new React\Socket\TimeoutConnector($connector, 10.0, $loop);
$timeoutConnector->connect('127.0.0.1:8080')->then(function (ConnectionInterface $connection) {/* bla bla */});
Link to comment
Share on other sites

Take a look at the code for Server and Connector and you can see the two pairs do the same thing.

 

Remember: PHP code is naturally open-source so if you have a question about how something works then you can simply look at the code to see what it does.

Link to comment
Share on other sites

Take a look at the code for Server and Connector and you can see the two pairs do the same thing.

 

Remember: PHP code is naturally open-source so if you have a question about how something works then you can simply look at the code to see what it does.

 

Hey!  It's just normal PHP! :)

 

I've been a little intimidated by these classes, but am less so now.  While it would have nice for the docs to indicated that they do the same thing, it is not that hard to verify.  Thanks for getting me to do what needs to be done.  By the way, the documents have gotten much better lately.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.