NotionCommotion Posted May 13, 2017 Share Posted May 13, 2017 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 Quote Link to comment Share on other sites More sharing options...
NotionCommotion Posted May 13, 2017 Author Share Posted May 13, 2017 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 */}); Quote Link to comment Share on other sites More sharing options...
requinix Posted May 13, 2017 Share Posted May 13, 2017 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. 1 Quote Link to comment Share on other sites More sharing options...
NotionCommotion Posted May 14, 2017 Author Share Posted May 14, 2017 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.