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.

  • Like 1
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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.