Skip to content

Commit 52f414e

Browse files
committed
Rename Server to TcpServer
1 parent 05b2fa7 commit 52f414e

14 files changed

+116
-116
lines changed

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ handle multiple concurrent connections without blocking.
3030
* [pause()](#pause)
3131
* [resume()](#resume)
3232
* [close()](#close)
33-
* [Server](#server)
33+
* [TcpServer](#tcpserver)
3434
* [SecureServer](#secureserver)
3535
* [LimitingServer](#limitingserver)
3636
* [getConnections()](#getconnections)
@@ -55,7 +55,7 @@ Here is a server that closes the connection if you send it anything:
5555
```php
5656
$loop = React\EventLoop\Factory::create();
5757

58-
$socket = new React\Socket\Server(8080, $loop);
58+
$socket = new React\Socket\TcpServer(8080, $loop);
5959
$socket->on('connection', function (ConnectionInterface $conn) {
6060
$conn->write("Hello " . $conn->getRemoteAddress() . "!\n");
6161
$conn->write("Welcome to this amazing server!\n");
@@ -173,7 +173,7 @@ Otherwise, it will return the full local address as a string value.
173173

174174
This method complements the [`getRemoteAddress()`](#getremoteaddress) method,
175175
so they should not be confused.
176-
If your `Server` instance is listening on multiple interfaces (e.g. using
176+
If your `TcpServer` instance is listening on multiple interfaces (e.g. using
177177
the address `0.0.0.0`), you can use this method to find out which interface
178178
actually accepted this connection (such as a public or local interface).
179179

@@ -319,13 +319,13 @@ $server->close();
319319

320320
Calling this method more than once on the same instance is a NO-OP.
321321

322-
### Server
322+
### TcpServer
323323

324-
The `Server` class implements the [`ServerInterface`](#serverinterface) and
324+
The `TcpServer` class implements the [`ServerInterface`](#serverinterface) and
325325
is responsible for accepting plaintext TCP/IP connections.
326326

327327
```php
328-
$server = new Server(8080, $loop);
328+
$server = new TcpServer(8080, $loop);
329329
```
330330

331331
As above, the `$uri` parameter can consist of only a port, in which case the
@@ -335,7 +335,7 @@ which means it will not be reachable from outside of this system.
335335
In order to use a random port assignment, you can use the port `0`:
336336

337337
```php
338-
$server = new Server(0, $loop);
338+
$server = new TcpServer(0, $loop);
339339
$address = $server->getAddress();
340340
```
341341

@@ -344,33 +344,33 @@ address through the first parameter provided to the constructor, optionally
344344
preceded by the `tcp://` scheme:
345345

346346
```php
347-
$server = new Server('192.168.0.1:8080', $loop);
347+
$server = new TcpServer('192.168.0.1:8080', $loop);
348348
```
349349

350350
If you want to listen on an IPv6 address, you MUST enclose the host in square
351351
brackets:
352352

353353
```php
354-
$server = new Server('[::1]:8080', $loop);
354+
$server = new TcpServer('[::1]:8080', $loop);
355355
```
356356

357357
If the given URI is invalid, does not contain a port, any other scheme or if it
358358
contains a hostname, it will throw an `InvalidArgumentException`:
359359

360360
```php
361361
// throws InvalidArgumentException due to missing port
362-
$server = new Server('127.0.0.1', $loop);
362+
$server = new TcpServer('127.0.0.1', $loop);
363363
```
364364

365365
If the given URI appears to be valid, but listening on it fails (such as if port
366366
is already in use or port below 1024 may require root access etc.), it will
367367
throw a `RuntimeException`:
368368

369369
```php
370-
$first = new Server(8080, $loop);
370+
$first = new TcpServer(8080, $loop);
371371

372372
// throws RuntimeException because port is already in use
373-
$second = new Server(8080, $loop);
373+
$second = new TcpServer(8080, $loop);
374374
```
375375

376376
> Note that these error conditions may vary depending on your system and/or
@@ -382,7 +382,7 @@ Optionally, you can specify [socket context options](http://php.net/manual/en/co
382382
for the underlying stream socket resource like this:
383383

384384
```php
385-
$server = new Server('[::1]:8080', $loop, array(
385+
$server = new TcpServer('[::1]:8080', $loop, array(
386386
'backlog' => 200,
387387
'so_reuseport' => true,
388388
'ipv6_v6only' => true
@@ -408,7 +408,7 @@ $server->on('connection', function (ConnectionInterface $connection) {
408408

409409
See also the [`ServerInterface`](#serverinterface) for more details.
410410

411-
Note that the `Server` class is a concrete implementation for TCP/IP sockets.
411+
Note that the `TcpServer` class is a concrete implementation for TCP/IP sockets.
412412
If you want to typehint in your higher-level protocol implementation, you SHOULD
413413
use the generic [`ServerInterface`](#serverinterface) instead.
414414

@@ -417,14 +417,14 @@ use the generic [`ServerInterface`](#serverinterface) instead.
417417
The `SecureServer` class implements the [`ServerInterface`](#serverinterface)
418418
and is responsible for providing a secure TLS (formerly known as SSL) server.
419419

420-
It does so by wrapping a [`Server`](#server) instance which waits for plaintext
420+
It does so by wrapping a [`TcpServer`](#tcpserver) instance which waits for plaintext
421421
TCP/IP connections and then performs a TLS handshake for each connection.
422422
It thus requires valid [TLS context options](http://php.net/manual/en/context.ssl.php),
423423
which in its most basic form may look something like this if you're using a
424424
PEM encoded certificate file:
425425

426426
```php
427-
$server = new Server(8000, $loop);
427+
$server = new TcpServer(8000, $loop);
428428
$server = new SecureServer($server, $loop, array(
429429
'local_cert' => 'server.pem'
430430
));
@@ -439,7 +439,7 @@ If your private key is encrypted with a passphrase, you have to specify it
439439
like this:
440440

441441
```php
442-
$server = new Server(8000, $loop);
442+
$server = new TcpServer(8000, $loop);
443443
$server = new SecureServer($server, $loop, array(
444444
'local_cert' => 'server.pem',
445445
'passphrase' => 'secret'
@@ -479,13 +479,13 @@ If you want to typehint in your higher-level protocol implementation, you SHOULD
479479
use the generic [`ServerInterface`](#serverinterface) instead.
480480

481481
> Advanced usage: Despite allowing any `ServerInterface` as first parameter,
482-
you SHOULD pass a `Server` instance as first parameter, unless you
482+
you SHOULD pass a `TcpServer` instance as first parameter, unless you
483483
know what you're doing.
484484
Internally, the `SecureServer` has to set the required TLS context options on
485485
the underlying stream resources.
486486
These resources are not exposed through any of the interfaces defined in this
487487
package, but only through the `React\Stream\Stream` class.
488-
The `Server` class is guaranteed to emit connections that implement
488+
The `TcpServer` class is guaranteed to emit connections that implement
489489
the `ConnectionInterface` and also extend the `Stream` class in order to
490490
expose these underlying resources.
491491
If you use a custom `ServerInterface` and its `connection` event does not

examples/01-echo.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
// $ openssl s_client -connect localhost:8000
1313

1414
use React\EventLoop\Factory;
15-
use React\Socket\Server;
15+
use React\Socket\TcpServer;
1616
use React\Socket\ConnectionInterface;
1717
use React\Socket\SecureServer;
1818

1919
require __DIR__ . '/../vendor/autoload.php';
2020

2121
$loop = Factory::create();
2222

23-
$server = new Server(isset($argv[1]) ? $argv[1] : 0, $loop);
23+
$server = new TcpServer(isset($argv[1]) ? $argv[1] : 0, $loop);
2424

2525
// secure TLS mode if certificate is given as second parameter
2626
if (isset($argv[2])) {

examples/02-chat-server.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// $ openssl s_client -connect localhost:8000
1313

1414
use React\EventLoop\Factory;
15-
use React\Socket\Server;
15+
use React\Socket\TcpServer;
1616
use React\Socket\ConnectionInterface;
1717
use React\Socket\SecureServer;
1818
use React\Socket\LimitingServer;
@@ -21,7 +21,7 @@
2121

2222
$loop = Factory::create();
2323

24-
$server = new Server(isset($argv[1]) ? $argv[1] : 0, $loop);
24+
$server = new TcpServer(isset($argv[1]) ? $argv[1] : 0, $loop);
2525

2626
// secure TLS mode if certificate is given as second parameter
2727
if (isset($argv[2])) {

examples/03-benchmark.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
// $ dd if=/dev/zero bs=1M count=1000 | openssl s_client -connect localhost:8000
1818

1919
use React\EventLoop\Factory;
20-
use React\Socket\Server;
20+
use React\Socket\TcpServer;
2121
use React\Socket\ConnectionInterface;
2222
use React\Socket\SecureServer;
2323

2424
require __DIR__ . '/../vendor/autoload.php';
2525

2626
$loop = Factory::create();
2727

28-
$server = new Server(isset($argv[1]) ? $argv[1] : 0, $loop);
28+
$server = new TcpServer(isset($argv[1]) ? $argv[1] : 0, $loop);
2929

3030
// secure TLS mode if certificate is given as second parameter
3131
if (isset($argv[2])) {

src/ConnectionInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public function getRemoteAddress();
9595
* This method complements the [`getRemoteAddress()`](#getremoteaddress) method,
9696
* so they should not be confused.
9797
*
98-
* If your `Server` instance is listening on multiple interfaces (e.g. using
98+
* If your `TcpServer` instance is listening on multiple interfaces (e.g. using
9999
* the address `0.0.0.0`), you can use this method to find out which interface
100100
* actually accepted this connection (such as a public or local interface).
101101
*

src/SecureServer.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44

55
use Evenement\EventEmitter;
66
use React\EventLoop\LoopInterface;
7-
use React\Socket\Server;
7+
use React\Socket\TcpServer;
88
use React\Socket\ConnectionInterface;
99
use React\Stream\Stream;
1010

1111
/**
1212
* The `SecureServer` class implements the `ServerInterface` and is responsible
1313
* for providing a secure TLS (formerly known as SSL) server.
1414
*
15-
* It does so by wrapping a `Server` instance which waits for plaintext
15+
* It does so by wrapping a `TcpServer` instance which waits for plaintext
1616
* TCP/IP connections and then performs a TLS handshake for each connection.
1717
*
1818
* ```php
19-
* $server = new Server(8000, $loop);
19+
* $server = new TcpServer(8000, $loop);
2020
* $server = new SecureServer($server, $loop, array(
2121
* // tls context options here…
2222
* ));
@@ -61,14 +61,14 @@ final class SecureServer extends EventEmitter implements ServerInterface
6161
/**
6262
* Creates a secure TLS server and starts waiting for incoming connections
6363
*
64-
* It does so by wrapping a `Server` instance which waits for plaintext
64+
* It does so by wrapping a `TcpServer` instance which waits for plaintext
6565
* TCP/IP connections and then performs a TLS handshake for each connection.
6666
* It thus requires valid [TLS context options],
6767
* which in its most basic form may look something like this if you're using a
6868
* PEM encoded certificate file:
6969
*
7070
* ```php
71-
* $server = new Server(8000, $loop);
71+
* $server = new TcpServer(8000, $loop);
7272
* $server = new SecureServer($server, $loop, array(
7373
* 'local_cert' => 'server.pem'
7474
* ));
@@ -83,7 +83,7 @@ final class SecureServer extends EventEmitter implements ServerInterface
8383
* like this:
8484
*
8585
* ```php
86-
* $server = new Server(8000, $loop);
86+
* $server = new TcpServer(8000, $loop);
8787
* $server = new SecureServer($server, $loop, array(
8888
* 'local_cert' => 'server.pem',
8989
* 'passphrase' => 'secret'
@@ -96,24 +96,24 @@ final class SecureServer extends EventEmitter implements ServerInterface
9696
* Passing unknown context options has no effect.
9797
*
9898
* Advanced usage: Despite allowing any `ServerInterface` as first parameter,
99-
* you SHOULD pass a `Server` instance as first parameter, unless you
99+
* you SHOULD pass a `TcpServer` instance as first parameter, unless you
100100
* know what you're doing.
101101
* Internally, the `SecureServer` has to set the required TLS context options on
102102
* the underlying stream resources.
103103
* These resources are not exposed through any of the interfaces defined in this
104104
* package, but only through the `React\Stream\Stream` class.
105-
* The `Server` class is guaranteed to emit connections that implement
105+
* The `TcpServer` class is guaranteed to emit connections that implement
106106
* the `ConnectionInterface` and also extend the `Stream` class in order to
107107
* expose these underlying resources.
108108
* If you use a custom `ServerInterface` and its `connection` event does not
109109
* meet this requirement, the `SecureServer` will emit an `error` event and
110110
* then close the underlying connection.
111111
*
112-
* @param ServerInterface|Server $tcp
112+
* @param ServerInterface|TcpServer $tcp
113113
* @param LoopInterface $loop
114114
* @param array $context
115115
* @throws \BadMethodCallException for legacy HHVM < 3.8 due to lack of support
116-
* @see Server
116+
* @see TcpServer
117117
* @link http://php.net/manual/en/context.ssl.php for TLS context options
118118
*/
119119
public function __construct(ServerInterface $tcp, LoopInterface $loop, array $context)

src/Server.php renamed to src/TcpServer.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
use RuntimeException;
99

1010
/**
11-
* The `Server` class implements the `ServerInterface` and
11+
* The `TcpServer` class implements the `ServerInterface` and
1212
* is responsible for accepting plaintext TCP/IP connections.
1313
*
1414
* ```php
15-
* $server = new Server(8080, $loop);
15+
* $server = new TcpServer(8080, $loop);
1616
* ```
1717
*
1818
* Whenever a client connects, it will emit a `connection` event with a connection
@@ -28,14 +28,14 @@
2828
*
2929
* See also the `ServerInterface` for more details.
3030
*
31-
* Note that the `Server` class is a concrete implementation for TCP/IP sockets.
31+
* Note that the `TcpServer` class is a concrete implementation for TCP/IP sockets.
3232
* If you want to typehint in your higher-level protocol implementation, you SHOULD
3333
* use the generic `ServerInterface` instead.
3434
*
3535
* @see ServerInterface
3636
* @see ConnectionInterface
3737
*/
38-
final class Server extends EventEmitter implements ServerInterface
38+
final class TcpServer extends EventEmitter implements ServerInterface
3939
{
4040
private $master;
4141
private $loop;
@@ -49,7 +49,7 @@ final class Server extends EventEmitter implements ServerInterface
4949
* for more details.
5050
*
5151
* ```php
52-
* $server = new Server(8080, $loop);
52+
* $server = new TcpServer(8080, $loop);
5353
* ```
5454
*
5555
* As above, the `$uri` parameter can consist of only a port, in which case the
@@ -59,7 +59,7 @@ final class Server extends EventEmitter implements ServerInterface
5959
* In order to use a random port assignment, you can use the port `0`:
6060
*
6161
* ```php
62-
* $server = new Server(0, $loop);
62+
* $server = new TcpServer(0, $loop);
6363
* $address = $server->getAddress();
6464
* ```
6565
*
@@ -68,33 +68,33 @@ final class Server extends EventEmitter implements ServerInterface
6868
* preceded by the `tcp://` scheme:
6969
*
7070
* ```php
71-
* $server = new Server('192.168.0.1:8080', $loop);
71+
* $server = new TcpServer('192.168.0.1:8080', $loop);
7272
* ```
7373
*
7474
* If you want to listen on an IPv6 address, you MUST enclose the host in square
7575
* brackets:
7676
*
7777
* ```php
78-
* $server = new Server('[::1]:8080', $loop);
78+
* $server = new TcpServer('[::1]:8080', $loop);
7979
* ```
8080
*
8181
* If the given URI is invalid, does not contain a port, any other scheme or if it
8282
* contains a hostname, it will throw an `InvalidArgumentException`:
8383
*
8484
* ```php
8585
* // throws InvalidArgumentException due to missing port
86-
* $server = new Server('127.0.0.1', $loop);
86+
* $server = new TcpServer('127.0.0.1', $loop);
8787
* ```
8888
*
8989
* If the given URI appears to be valid, but listening on it fails (such as if port
9090
* is already in use or port below 1024 may require root access etc.), it will
9191
* throw a `RuntimeException`:
9292
*
9393
* ```php
94-
* $first = new Server(8080, $loop);
94+
* $first = new TcpServer(8080, $loop);
9595
*
9696
* // throws RuntimeException because port is already in use
97-
* $second = new Server(8080, $loop);
97+
* $second = new TcpServer(8080, $loop);
9898
* ```
9999
*
100100
* Note that these error conditions may vary depending on your system and/or
@@ -106,7 +106,7 @@ final class Server extends EventEmitter implements ServerInterface
106106
* for the underlying stream socket resource like this:
107107
*
108108
* ```php
109-
* $server = new Server('[::1]:8080', $loop, array(
109+
* $server = new TcpServer('[::1]:8080', $loop, array(
110110
* 'backlog' => 200,
111111
* 'so_reuseport' => true,
112112
* 'ipv6_v6only' => true

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy