Skip to content

Commit e514db1

Browse files
committed
Add documentation to client examples
1 parent 0f075a7 commit e514db1

4 files changed

Lines changed: 31 additions & 0 deletions

File tree

examples/11-http.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<?php
22

3+
// Simple plaintext HTTP client example (for illustration purposes only).
4+
// This shows how a plaintext TCP/IP connection is established to then send an
5+
// application level protocol message (HTTP).
6+
// Real applications should use react/http-client instead
7+
38
use React\EventLoop\Factory;
49
use React\Socket\Connector;
510
use React\Socket\ConnectionInterface;

examples/12-https.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<?php
22

3+
// Simple secure HTTPS client example (for illustration purposes only).
4+
// This shows how a secure TLS connection is established to then send an
5+
// application level protocol message (HTTP).
6+
// Real applications should use react/http-client instead
7+
38
use React\EventLoop\Factory;
49
use React\Socket\Connector;
510
use React\Socket\ConnectionInterface;

examples/13-netcat.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
<?php
22

3+
// Simple plaintext TCP/IP and secure TLS client example that pipes console I/O.
4+
// This shows how a plaintext TCP/IP or secure TLS connection is established and
5+
// then everything you type on STDIN will be sent and everything the server
6+
// sends will be piped to your STDOUT.
7+
38
use React\EventLoop\Factory;
49
use React\Socket\Connector;
510
use React\Socket\ConnectionInterface;
@@ -8,6 +13,16 @@
813

914
require __DIR__ . '/../vendor/autoload.php';
1015

16+
if (!defined('STDIN')) {
17+
echo 'STDIO streams require CLI SAPI' . PHP_EOL;
18+
exit(1);
19+
}
20+
21+
if (DIRECTORY_SEPARATOR === '\\') {
22+
fwrite(STDERR, 'Non-blocking console I/O not supported on Microsoft Windows' . PHP_EOL);
23+
exit(1);
24+
}
25+
1126
if (!isset($argv[1])) {
1227
fwrite(STDERR, 'Usage error: required argument <host:port>' . PHP_EOL);
1328
exit(1);

examples/14-web.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
<?php
22

3+
// Simple plaintext HTTP and secure HTTPS client example (for illustration purposes only).
4+
// This shows how an URI parameter can parsed to decide whether to establish
5+
// a plaintext TCP/IP or secure TLS connection and then send an
6+
// application level protocol message (HTTP).
7+
// Real applications should use react/http-client instead
8+
39
use React\EventLoop\Factory;
410
use React\Socket\ConnectionInterface;
511
use React\Socket\Connector;

0 commit comments

Comments
 (0)