@@ -423,13 +423,13 @@ Optionally, you can specify [TCP socket context options](https://www.php.net/man
423
423
for the underlying stream socket resource like this:
424
424
425
425
``` php
426
- $socket = new React\Socket\SocketServer('[::1]:8080', array(
427
- 'tcp' => array(
426
+ $socket = new React\Socket\SocketServer('[::1]:8080', [
427
+ 'tcp' => [
428
428
'backlog' => 200,
429
429
'so_reuseport' => true,
430
430
'ipv6_v6only' => true
431
- )
432
- ) );
431
+ ]
432
+ ] );
433
433
```
434
434
435
435
> Note that available [ socket context options] ( https://www.php.net/manual/en/context.socket.php ) ,
@@ -447,11 +447,11 @@ which in its most basic form may look something like this if you're using a
447
447
PEM encoded certificate file:
448
448
449
449
``` php
450
- $socket = new React\Socket\SocketServer('tls://127.0.0.1:8080', array(
451
- 'tls' => array(
450
+ $socket = new React\Socket\SocketServer('tls://127.0.0.1:8080', [
451
+ 'tls' => [
452
452
'local_cert' => 'server.pem'
453
- )
454
- ) );
453
+ ]
454
+ ] );
455
455
```
456
456
457
457
> Note that the certificate file will not be loaded on instantiation but when an
@@ -463,25 +463,25 @@ If your private key is encrypted with a passphrase, you have to specify it
463
463
like this:
464
464
465
465
``` php
466
- $socket = new React\Socket\SocketServer('tls://127.0.0.1:8000', array(
467
- 'tls' => array(
466
+ $socket = new React\Socket\SocketServer('tls://127.0.0.1:8000', [
467
+ 'tls' => [
468
468
'local_cert' => 'server.pem',
469
469
'passphrase' => 'secret'
470
- )
471
- ) );
470
+ ]
471
+ ] );
472
472
```
473
473
474
474
By default, this server supports TLSv1.0+ and excludes support for legacy
475
475
SSLv2/SSLv3. You can also explicitly choose the TLS version you
476
476
want to negotiate with the remote side:
477
477
478
478
``` php
479
- $socket = new React\Socket\SocketServer('tls://127.0.0.1:8000', array(
480
- 'tls' => array(
479
+ $socket = new React\Socket\SocketServer('tls://127.0.0.1:8000', [
480
+ 'tls' => [
481
481
'local_cert' => 'server.pem',
482
482
'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_SERVER
483
- )
484
- ) );
483
+ ]
484
+ ] );
485
485
```
486
486
487
487
> Note that available [ TLS context options] ( https://www.php.net/manual/en/context.ssl.php ) ,
@@ -588,11 +588,11 @@ Optionally, you can specify [socket context options](https://www.php.net/manual/
588
588
for the underlying stream socket resource like this:
589
589
590
590
``` php
591
- $server = new React\Socket\TcpServer('[::1]:8080', null, array(
591
+ $server = new React\Socket\TcpServer('[::1]:8080', null, [
592
592
'backlog' => 200,
593
593
'so_reuseport' => true,
594
594
'ipv6_v6only' => true
595
- ) );
595
+ ] );
596
596
```
597
597
598
598
> Note that available [ socket context options] ( https://www.php.net/manual/en/context.socket.php ) ,
@@ -628,9 +628,9 @@ PEM encoded certificate file:
628
628
629
629
``` php
630
630
$server = new React\Socket\TcpServer(8000);
631
- $server = new React\Socket\SecureServer($server, null, array(
631
+ $server = new React\Socket\SecureServer($server, null, [
632
632
'local_cert' => 'server.pem'
633
- ) );
633
+ ] );
634
634
```
635
635
636
636
> Note that the certificate file will not be loaded on instantiation but when an
@@ -643,10 +643,10 @@ like this:
643
643
644
644
``` php
645
645
$server = new React\Socket\TcpServer(8000);
646
- $server = new React\Socket\SecureServer($server, null, array(
646
+ $server = new React\Socket\SecureServer($server, null, [
647
647
'local_cert' => 'server.pem',
648
648
'passphrase' => 'secret'
649
- ) );
649
+ ] );
650
650
```
651
651
652
652
By default, this server supports TLSv1.0+ and excludes support for legacy
@@ -655,10 +655,10 @@ want to negotiate with the remote side:
655
655
656
656
``` php
657
657
$server = new React\Socket\TcpServer(8000);
658
- $server = new React\Socket\SecureServer($server, null, array(
658
+ $server = new React\Socket\SecureServer($server, null, [
659
659
'local_cert' => 'server.pem',
660
660
'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_SERVER
661
- ) );
661
+ ] );
662
662
```
663
663
664
664
> Note that available [ TLS context options] ( https://www.php.net/manual/en/context.ssl.php ) ,
@@ -971,9 +971,9 @@ If you want to revert to the old behavior of only doing an IPv4 lookup and
971
971
only attempt a single IPv4 connection, you can set up the ` Connector ` like this:
972
972
973
973
``` php
974
- $connector = new React\Socket\Connector(array(
974
+ $connector = new React\Socket\Connector([
975
975
'happy_eyeballs' => false
976
- ) );
976
+ ] );
977
977
```
978
978
979
979
Similarly, you can also affect the default DNS behavior as follows.
@@ -985,9 +985,9 @@ If you explicitly want to use a custom DNS server (such as a local DNS relay or
985
985
a company wide DNS server), you can set up the ` Connector ` like this:
986
986
987
987
``` php
988
- $connector = new React\Socket\Connector(array(
988
+ $connector = new React\Socket\Connector([
989
989
'dns' => '127.0.1.1'
990
- ) );
990
+ ] );
991
991
992
992
$connector->connect('localhost:80')->then(function (React\Socket\ConnectionInterface $connection) {
993
993
$connection->write('...');
@@ -999,9 +999,9 @@ If you do not want to use a DNS resolver at all and want to connect to IP
999
999
addresses only, you can also set up your ` Connector ` like this:
1000
1000
1001
1001
``` php
1002
- $connector = new React\Socket\Connector(array(
1002
+ $connector = new React\Socket\Connector([
1003
1003
'dns' => false
1004
- ) );
1004
+ ] );
1005
1005
1006
1006
$connector->connect('127.0.0.1:80')->then(function (React\Socket\ConnectionInterface $connection) {
1007
1007
$connection->write('...');
@@ -1016,9 +1016,9 @@ can also set up your `Connector` like this:
1016
1016
$dnsResolverFactory = new React\Dns\Resolver\Factory();
1017
1017
$resolver = $dnsResolverFactory->createCached('127.0.1.1');
1018
1018
1019
- $connector = new React\Socket\Connector(array(
1019
+ $connector = new React\Socket\Connector([
1020
1020
'dns' => $resolver
1021
- ) );
1021
+ ] );
1022
1022
1023
1023
$connector->connect('localhost:80')->then(function (React\Socket\ConnectionInterface $connection) {
1024
1024
$connection->write('...');
@@ -1031,18 +1031,18 @@ respects your `default_socket_timeout` ini setting (which defaults to 60s).
1031
1031
If you want a custom timeout value, you can simply pass this like this:
1032
1032
1033
1033
``` php
1034
- $connector = new React\Socket\Connector(array(
1034
+ $connector = new React\Socket\Connector([
1035
1035
'timeout' => 10.0
1036
- ) );
1036
+ ] );
1037
1037
```
1038
1038
1039
1039
Similarly, if you do not want to apply a timeout at all and let the operating
1040
1040
system handle this, you can pass a boolean flag like this:
1041
1041
1042
1042
``` php
1043
- $connector = new React\Socket\Connector(array(
1043
+ $connector = new React\Socket\Connector([
1044
1044
'timeout' => false
1045
- ) );
1045
+ ] );
1046
1046
```
1047
1047
1048
1048
By default, the ` Connector ` supports the ` tcp:// ` , ` tls:// ` and ` unix:// `
@@ -1051,7 +1051,7 @@ pass boolean flags like this:
1051
1051
1052
1052
``` php
1053
1053
// only allow secure TLS connections
1054
- $connector = new React\Socket\Connector(array(
1054
+ $connector = new React\Socket\Connector([
1055
1055
'tcp' => false,
1056
1056
'tls' => true,
1057
1057
'unix' => false,
@@ -1070,15 +1070,15 @@ pass arrays of context options like this:
1070
1070
1071
1071
``` php
1072
1072
// allow insecure TLS connections
1073
- $connector = new React\Socket\Connector(array(
1074
- 'tcp' => array(
1073
+ $connector = new React\Socket\Connector([
1074
+ 'tcp' => [
1075
1075
'bindto' => '192.168.0.1:0'
1076
- ) ,
1077
- 'tls' => array(
1076
+ ] ,
1077
+ 'tls' => [
1078
1078
'verify_peer' => false,
1079
1079
'verify_peer_name' => false
1080
- ) ,
1081
- ) );
1080
+ ] ,
1081
+ ] );
1082
1082
1083
1083
$connector->connect('tls://localhost:443')->then(function (React\Socket\ConnectionInterface $connection) {
1084
1084
$connection->write('...');
@@ -1091,11 +1091,11 @@ SSLv2/SSLv3. You can also explicitly choose the TLS version you
1091
1091
want to negotiate with the remote side:
1092
1092
1093
1093
``` php
1094
- $connector = new React\Socket\Connector(array(
1095
- 'tls' => array(
1094
+ $connector = new React\Socket\Connector([
1095
+ 'tls' => [
1096
1096
'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
1097
- )
1098
- ) );
1097
+ ]
1098
+ ] );
1099
1099
```
1100
1100
1101
1101
> For more details about context options, please refer to the PHP documentation
@@ -1117,14 +1117,14 @@ $tls = new React\Socket\SecureConnector($tcp);
1117
1117
1118
1118
$unix = new React\Socket\UnixConnector();
1119
1119
1120
- $connector = new React\Socket\Connector(array(
1120
+ $connector = new React\Socket\Connector([
1121
1121
'tcp' => $tcp,
1122
1122
'tls' => $tls,
1123
1123
'unix' => $unix,
1124
1124
1125
1125
'dns' => false,
1126
1126
'timeout' => false,
1127
- ) );
1127
+ ] );
1128
1128
1129
1129
$connector->connect('google.com:80')->then(function (React\Socket\ConnectionInterface $connection) {
1130
1130
$connection->write('...');
@@ -1192,9 +1192,9 @@ You can optionally pass additional
1192
1192
to the constructor like this:
1193
1193
1194
1194
``` php
1195
- $tcpConnector = new React\Socket\TcpConnector(null, array(
1195
+ $tcpConnector = new React\Socket\TcpConnector(null, [
1196
1196
'bindto' => '192.168.0.1:0'
1197
- ) );
1197
+ ] );
1198
1198
```
1199
1199
1200
1200
Note that this class only allows you to connect to IP-port-combinations.
@@ -1363,20 +1363,20 @@ You can optionally pass additional
1363
1363
to the constructor like this:
1364
1364
1365
1365
``` php
1366
- $secureConnector = new React\Socket\SecureConnector($dnsConnector, null, array(
1366
+ $secureConnector = new React\Socket\SecureConnector($dnsConnector, null, [
1367
1367
'verify_peer' => false,
1368
1368
'verify_peer_name' => false
1369
- ) );
1369
+ ] );
1370
1370
```
1371
1371
1372
1372
By default, this connector supports TLSv1.0+ and excludes support for legacy
1373
1373
SSLv2/SSLv3. You can also explicitly choose the TLS version you
1374
1374
want to negotiate with the remote side:
1375
1375
1376
1376
``` php
1377
- $secureConnector = new React\Socket\SecureConnector($dnsConnector, null, array(
1377
+ $secureConnector = new React\Socket\SecureConnector($dnsConnector, null, [
1378
1378
'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT
1379
- ) );
1379
+ ] );
1380
1380
```
1381
1381
1382
1382
> Advanced usage: Internally, the ` SecureConnector ` relies on setting up the
0 commit comments