File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -37,7 +37,9 @@ $loop->start();
3737The ` Socks/Client ` uses a [ Promise] ( https://github.com/reactphp/promise ) -based interface which makes working with asynchronous functions a breeze.
3838Let's open up a TCP [ Stream] ( https://github.com/reactphp/stream ) connection and write some data:
3939``` PHP
40- $client->getConnection('www.google.com',80)->then(function (React\Stream\Stream $stream) {
40+ $tcp = $client->createConnector();
41+
42+ $tcp->create('www.google.com',80)->then(function (React\Stream\Stream $stream) {
4143 echo 'connected to www.google.com:80';
4244 $stream->write("GET / HTTP/1.0\r\n\r\n");
4345 // ...
@@ -67,10 +69,10 @@ Yes, this works for both plain HTTP and SSL encrypted HTTPS requests.
6769
6870If you want to connect to arbitrary SSL/TLS servers, there sure too is an easy to use API available:
6971``` PHP
70- $ssl = $client->createSecureConnectionManager ();
72+ $ssl = $client->createSecureConnector ();
7173
72- // now create an SSL encrypted connection (notice the $ssl instead of $client )
73- $ssl->getConnection ('www.google.com',443)->then(function (React\Stream\Stream $stream) {
74+ // now create an SSL encrypted connection (notice the $ssl instead of $tcp )
75+ $ssl->create ('www.google.com',443)->then(function (React\Stream\Stream $stream) {
7476 // proceed with just the plain text data and everything is encrypted/decrypted automatically
7577 echo 'connected to SSL encrypted www.google.com';
7678 $stream->write("GET / HTTP/1.0\r\n\r\n");
You can’t perform that action at this time.
0 commit comments