File tree Expand file tree Collapse file tree 5 files changed +17
-7
lines changed
Expand file tree Collapse file tree 5 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -82,6 +82,8 @@ $connector = new React\Socket\Connector();
8282$connector->connect('127.0.0.1:8080')->then(function (React\Socket\ConnectionInterface $connection) {
8383 $connection->pipe(new React\Stream\WritableResourceStream(STDOUT));
8484 $connection->write("Hello World!\n");
85+ }, function (Exception $e) {
86+ echo 'Error: ' . $e->getMessage() . PHP_EOL;
8587});
8688```
8789
@@ -905,6 +907,8 @@ $connector = new React\Socket\Connector();
905907$connector->connect($uri)->then(function (React\Socket\ConnectionInterface $connection) {
906908 $connection->write('...');
907909 $connection->end();
910+ }, function (Exception $e) {
911+ echo 'Error: ' . $e->getMessage() . PHP_EOL;
908912});
909913```
910914
Original file line number Diff line number Diff line change 2929 });
3030
3131 $ connection ->write ("GET / HTTP/1.0 \r\nHost: $ host \r\n\r\n" );
32- }, 'printf ' );
32+ }, function (Exception $ e ) {
33+ echo 'Error: ' . $ e ->getMessage () . PHP_EOL ;
34+ });
Original file line number Diff line number Diff line change 2929 });
3030
3131 $ connection ->write ("GET / HTTP/1.0 \r\nHost: $ host \r\n\r\n" );
32- }, 'printf ' );
32+ }, function (Exception $ e ) {
33+ echo 'Error: ' . $ e ->getMessage () . PHP_EOL ;
34+ });
Original file line number Diff line number Diff line change 4848 $ connection ->pipe ($ stdout );
4949
5050 // report errors to STDERR
51- $ connection ->on ('error ' , function ($ error ) use ($ stderr ) {
52- $ stderr ->write ('Stream ERROR : ' . $ error . PHP_EOL );
51+ $ connection ->on ('error ' , function (Exception $ e ) use ($ stderr ) {
52+ $ stderr ->write ('Stream error : ' . $ e -> getMessage () . PHP_EOL );
5353 });
5454
5555 // report closing and stop reading from input
5959 });
6060
6161 $ stderr ->write ('Connected ' . PHP_EOL );
62- }, function ($ error ) use ($ stderr ) {
63- $ stderr ->write ('Connection ERROR : ' . $ error . PHP_EOL );
62+ }, function (Exception $ e ) use ($ stderr ) {
63+ $ stderr ->write ('Connection error : ' . $ e -> getMessage () . PHP_EOL );
6464});
Original file line number Diff line number Diff line change 5353 $ connection ->pipe ($ stdout );
5454
5555 $ connection ->write ("GET $ resource HTTP/1.0 \r\nHost: $ host \r\n\r\n" );
56- }, 'printf ' );
56+ }, function (Exception $ e ) {
57+ echo 'Error: ' . $ e ->getMessage () . PHP_EOL ;
58+ });
You can’t perform that action at this time.
0 commit comments