You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+20-10Lines changed: 20 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ Among others, multicast networking is the basis for:
19
19
*[Factory](#factory)
20
20
*[createSender()](#createsender)
21
21
*[createReceiver()](#createreceiver)
22
-
*[Socket](#socket)
22
+
*[SocketInterface](#socketinterface)
23
23
*[Install](#install)
24
24
*[Tests](#tests)
25
25
*[License](#license)
@@ -48,7 +48,7 @@ See also the [examples](examples).
48
48
49
49
### Factory
50
50
51
-
The `Factory` is responsible for creating your [`Socket`](#socket) instances.
51
+
The `Factory` is responsible for creating your [`SocketInterface`](#socketinterface) instances.
52
52
It also registers everything with the main [`EventLoop`](https://github.com/reactphp/event-loop#usage).
53
53
54
54
```php
@@ -58,7 +58,9 @@ $factory = new Factory($loop);
58
58
59
59
#### createSender()
60
60
61
-
The `createSender()` method can be used to create a socket capable of sending outgoing multicast datagrams and receiving incoming unicast responses. It returns a [`Socket`](#socket) instance.
61
+
The `createSender(): SocketInterface` method can be used to
62
+
create a socket capable of sending outgoing multicast datagrams and receiving
63
+
incoming unicast responses. It returns a [`SocketInterface`](#socketinterface) instance.
62
64
63
65
```php
64
66
$socket = $factory->createSender();
@@ -73,11 +75,13 @@ $socket->on('message', function ($data, $address) {
73
75
```
74
76
75
77
This method works on PHP versions as old as PHP 5.3 (and up), as its socket API has always been
The `createReceiver($address)` method can be used to create a socket capable of receiving incoming multicast datagrams and sending outgoing unicast or multicast datagrams. It returns a [`Socket`](#socket) instance.
82
+
The `createReceiver(string $address): SocketInterface` method can be used to
83
+
create a socket capable of receiving incoming multicast datagrams and sending
84
+
outgoing unicast or multicast datagrams. It returns a [`SocketInterface`](#socketinterface) instance.
@@ -104,12 +108,14 @@ to the newer stream based networking API.
104
108
Internally, this library uses a workaround to create stream based sockets
105
109
and then sets the required socket options on its underlying low level socket
106
110
resource.
107
-
This is done because React PHP is built around the general purpose stream based API
111
+
This is done because ReactPHP is built around the general purpose stream based API
108
112
and has only somewhat limited support for the low level socket API.
109
113
110
-
### Socket
114
+
### SocketInterface
111
115
112
-
The [`Factory`](#factory) creates instances of the `React\Datagram\Socket` class from the [react/datagram](https://github.com/reactphp/datagram) package.
116
+
The [`Factory`](#factory) creates instances of the `React\Datagram\SocketInterface`
117
+
from the [react/datagram](https://github.com/reactphp/datagram) package.
118
+
This means that you can use all its normal methods like so:
113
119
114
120
```php
115
121
$socket->send($message, $address);
@@ -140,6 +146,10 @@ extensions and supports running on legacy PHP 5.3 through current PHP 7+ and
140
146
HHVM.
141
147
It's *highly recommended to use PHP 7+* for this project.
142
148
149
+
The [`createSender()`](#createsender) method works on all supported platforms
150
+
without any additional requirements. However, the [`createReceiver()`](#createreceiver)
151
+
method requires PHP 5.4 (or up) and `ext-sockets`. See above for more details.
152
+
143
153
## Tests
144
154
145
155
To run the test suite, you first need to clone this repo and then install all
0 commit comments