@@ -30,7 +30,7 @@ handle multiple concurrent connections without blocking.
30
30
* [ pause()] ( #pause )
31
31
* [ resume()] ( #resume )
32
32
* [ close()] ( #close )
33
- * [ Server ] ( #server )
33
+ * [ TcpServer ] ( #tcpserver )
34
34
* [ SecureServer] ( #secureserver )
35
35
* [ LimitingServer] ( #limitingserver )
36
36
* [ getConnections()] ( #getconnections )
@@ -55,7 +55,7 @@ Here is a server that closes the connection if you send it anything:
55
55
``` php
56
56
$loop = React\EventLoop\Factory::create();
57
57
58
- $socket = new React\Socket\Server (8080, $loop);
58
+ $socket = new React\Socket\TcpServer (8080, $loop);
59
59
$socket->on('connection', function (ConnectionInterface $conn) {
60
60
$conn->write("Hello " . $conn->getRemoteAddress() . "!\n");
61
61
$conn->write("Welcome to this amazing server!\n");
@@ -173,7 +173,7 @@ Otherwise, it will return the full local address as a string value.
173
173
174
174
This method complements the [ ` getRemoteAddress() ` ] ( #getremoteaddress ) method,
175
175
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
177
177
the address ` 0.0.0.0 ` ), you can use this method to find out which interface
178
178
actually accepted this connection (such as a public or local interface).
179
179
@@ -319,13 +319,13 @@ $server->close();
319
319
320
320
Calling this method more than once on the same instance is a NO-OP.
321
321
322
- ### Server
322
+ ### TcpServer
323
323
324
- The ` Server ` class implements the [ ` ServerInterface ` ] ( #serverinterface ) and
324
+ The ` TcpServer ` class implements the [ ` ServerInterface ` ] ( #serverinterface ) and
325
325
is responsible for accepting plaintext TCP/IP connections.
326
326
327
327
``` php
328
- $server = new Server (8080, $loop);
328
+ $server = new TcpServer (8080, $loop);
329
329
```
330
330
331
331
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.
335
335
In order to use a random port assignment, you can use the port ` 0 ` :
336
336
337
337
``` php
338
- $server = new Server (0, $loop);
338
+ $server = new TcpServer (0, $loop);
339
339
$address = $server->getAddress();
340
340
```
341
341
@@ -344,33 +344,33 @@ address through the first parameter provided to the constructor, optionally
344
344
preceded by the ` tcp:// ` scheme:
345
345
346
346
``` php
347
- $server = new Server ('192.168.0.1:8080', $loop);
347
+ $server = new TcpServer ('192.168.0.1:8080', $loop);
348
348
```
349
349
350
350
If you want to listen on an IPv6 address, you MUST enclose the host in square
351
351
brackets:
352
352
353
353
``` php
354
- $server = new Server ('[::1]:8080', $loop);
354
+ $server = new TcpServer ('[::1]:8080', $loop);
355
355
```
356
356
357
357
If the given URI is invalid, does not contain a port, any other scheme or if it
358
358
contains a hostname, it will throw an ` InvalidArgumentException ` :
359
359
360
360
``` php
361
361
// throws InvalidArgumentException due to missing port
362
- $server = new Server ('127.0.0.1', $loop);
362
+ $server = new TcpServer ('127.0.0.1', $loop);
363
363
```
364
364
365
365
If the given URI appears to be valid, but listening on it fails (such as if port
366
366
is already in use or port below 1024 may require root access etc.), it will
367
367
throw a ` RuntimeException ` :
368
368
369
369
``` php
370
- $first = new Server (8080, $loop);
370
+ $first = new TcpServer (8080, $loop);
371
371
372
372
// throws RuntimeException because port is already in use
373
- $second = new Server (8080, $loop);
373
+ $second = new TcpServer (8080, $loop);
374
374
```
375
375
376
376
> 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
382
382
for the underlying stream socket resource like this:
383
383
384
384
``` php
385
- $server = new Server ('[::1]:8080', $loop, array(
385
+ $server = new TcpServer ('[::1]:8080', $loop, array(
386
386
'backlog' => 200,
387
387
'so_reuseport' => true,
388
388
'ipv6_v6only' => true
@@ -408,7 +408,7 @@ $server->on('connection', function (ConnectionInterface $connection) {
408
408
409
409
See also the [ ` ServerInterface ` ] ( #serverinterface ) for more details.
410
410
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.
412
412
If you want to typehint in your higher-level protocol implementation, you SHOULD
413
413
use the generic [ ` ServerInterface ` ] ( #serverinterface ) instead.
414
414
@@ -417,14 +417,14 @@ use the generic [`ServerInterface`](#serverinterface) instead.
417
417
The ` SecureServer ` class implements the [ ` ServerInterface ` ] ( #serverinterface )
418
418
and is responsible for providing a secure TLS (formerly known as SSL) server.
419
419
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
421
421
TCP/IP connections and then performs a TLS handshake for each connection.
422
422
It thus requires valid [ TLS context options] ( http://php.net/manual/en/context.ssl.php ) ,
423
423
which in its most basic form may look something like this if you're using a
424
424
PEM encoded certificate file:
425
425
426
426
``` php
427
- $server = new Server (8000, $loop);
427
+ $server = new TcpServer (8000, $loop);
428
428
$server = new SecureServer($server, $loop, array(
429
429
'local_cert' => 'server.pem'
430
430
));
@@ -439,7 +439,7 @@ If your private key is encrypted with a passphrase, you have to specify it
439
439
like this:
440
440
441
441
``` php
442
- $server = new Server (8000, $loop);
442
+ $server = new TcpServer (8000, $loop);
443
443
$server = new SecureServer($server, $loop, array(
444
444
'local_cert' => 'server.pem',
445
445
'passphrase' => 'secret'
@@ -479,13 +479,13 @@ If you want to typehint in your higher-level protocol implementation, you SHOULD
479
479
use the generic [ ` ServerInterface ` ] ( #serverinterface ) instead.
480
480
481
481
> 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
483
483
know what you're doing.
484
484
Internally, the ` SecureServer ` has to set the required TLS context options on
485
485
the underlying stream resources.
486
486
These resources are not exposed through any of the interfaces defined in this
487
487
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
489
489
the ` ConnectionInterface ` and also extend the ` Stream ` class in order to
490
490
expose these underlying resources.
491
491
If you use a custom ` ServerInterface ` and its ` connection ` event does not
0 commit comments