aboutsummaryrefslogtreecommitdiffhomepage
path: root/assets/php/vendor/react/socket/examples/21-netcat-client.php
diff options
context:
space:
mode:
authormarvin-borner@live.com2018-04-16 21:09:05 +0200
committermarvin-borner@live.com2018-04-16 21:09:05 +0200
commitcf14306c2b3f82a81f8d56669a71633b4d4b5fce (patch)
tree86700651aa180026e89a66064b0364b1e4346f3f /assets/php/vendor/react/socket/examples/21-netcat-client.php
parent619b01b3615458c4ed78bfaeabb6b1a47cc8ad8b (diff)
Main merge to user management system - files are now at /main/public/
Diffstat (limited to 'assets/php/vendor/react/socket/examples/21-netcat-client.php')
-rwxr-xr-xassets/php/vendor/react/socket/examples/21-netcat-client.php68
1 files changed, 0 insertions, 68 deletions
diff --git a/assets/php/vendor/react/socket/examples/21-netcat-client.php b/assets/php/vendor/react/socket/examples/21-netcat-client.php
deleted file mode 100755
index 9140e2c..0000000
--- a/assets/php/vendor/react/socket/examples/21-netcat-client.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-
-// Simple plaintext TCP/IP and secure TLS client example that pipes console I/O.
-// This shows how a plaintext TCP/IP or secure TLS connection is established and
-// then everything you type on STDIN will be sent and everything the server
-// sends will be piped to your STDOUT.
-//
-// $ php examples/21-netcat-client.php www.google.com:80
-// $ php examples/21-netcat-client.php tls://www.google.com:443
-
-use React\EventLoop\Factory;
-use React\Socket\Connector;
-use React\Socket\ConnectionInterface;
-use React\Stream\ReadableResourceStream;
-use React\Stream\WritableResourceStream;
-
-require __DIR__ . '/../vendor/autoload.php';
-
-if (!defined('STDIN')) {
- echo 'STDIO streams require CLI SAPI' . PHP_EOL;
- exit(1);
-}
-
-if (DIRECTORY_SEPARATOR === '\\') {
- fwrite(STDERR, 'Non-blocking console I/O not supported on Microsoft Windows' . PHP_EOL);
- exit(1);
-}
-
-if (!isset($argv[1])) {
- fwrite(STDERR, 'Usage error: required argument <host:port>' . PHP_EOL);
- exit(1);
-}
-
-$loop = Factory::create();
-$connector = new Connector($loop);
-
-$stdin = new ReadableResourceStream(STDIN, $loop);
-$stdin->pause();
-$stdout = new WritableResourceStream(STDOUT, $loop);
-$stderr = new WritableResourceStream(STDERR, $loop);
-
-$stderr->write('Connecting' . PHP_EOL);
-
-$connector->connect($argv[1])->then(function (ConnectionInterface $connection) use ($stdin, $stdout, $stderr) {
- // pipe everything from STDIN into connection
- $stdin->resume();
- $stdin->pipe($connection);
-
- // pipe everything from connection to STDOUT
- $connection->pipe($stdout);
-
- // report errors to STDERR
- $connection->on('error', function ($error) use ($stderr) {
- $stderr->write('Stream ERROR: ' . $error . PHP_EOL);
- });
-
- // report closing and stop reading from input
- $connection->on('close', function () use ($stderr, $stdin) {
- $stderr->write('[CLOSED]' . PHP_EOL);
- $stdin->close();
- });
-
- $stderr->write('Connected' . PHP_EOL);
-}, function ($error) use ($stderr) {
- $stderr->write('Connection ERROR: ' . $error . PHP_EOL);
-});
-
-$loop->run();