Skip to content

Commit 7708eac

Browse files
committed
Better documentation for required versions and extensions
1 parent 1e5b10b commit 7708eac

1 file changed

Lines changed: 19 additions & 20 deletions

File tree

README.md

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,29 @@ $factory = new Factory($loop);
5050

5151
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.
5252

53+
This method works on PHP versions as old as PHP 5.3 (and up), as its socket API has always been
54+
[level 1 multicast conformant](http://www.tldp.org/HOWTO/Multicast-HOWTO-2.html#ss2.2).
55+
5356
#### createReceiver()
5457

5558
The `createSender($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.
5659

60+
This method requires PHP 5.4 (or up) and ext-sockets.
61+
Otherwise, it will throw a `BadMethodCallException`.
62+
This is a requirement because receiving multicast datagrams requires a
63+
[level 2 multicast conformant](http://www.tldp.org/HOWTO/Multicast-HOWTO-2.html#ss2.2)
64+
socket API.
65+
The required multicast socket options and constants have been added with
66+
[PHP 5.4](http://php.net/manual/en/migration54.global-constants.php) (and up).
67+
These options are only available to the low level socket API (ext-sockets), not
68+
to the newer stream based networking API.
69+
70+
Internally, this library uses a workaround to create stream based sockets
71+
and then sets the required socket options on its underlying low level socket
72+
resource.
73+
This is done because React PHP is built around the general purpose stream based API
74+
and has only somewhat limited support for the low level socket API.
75+
5776
### Socket
5877

5978
The [`Factory`](#factory) creates instances of the `React\Datagram\Socket` class from the [react/datagram](https://github.com/reactphp/datagram) package.
@@ -73,26 +92,6 @@ $socket->close();
7392

7493
Please refer to the [datagram documentation](https://github.com/reactphp/datagram#usage) for more details.
7594

76-
## Description
77-
78-
[PHP 5.4 added support](http://php.net/manual/en/migration54.global-constants.php)
79-
for the required multicast socket options and constants.
80-
81-
These options are only available to the low level socket API (ext-sockets), not
82-
to the newer stream based networking API.
83-
For the most part, React PHP is built around the general purpose stream based API
84-
and has only somewhat limited support for the low level socket API.
85-
Because of this, this library uses a workaround to create stream based sockets
86-
and then sets the required socket options on its underlying low level socket
87-
resource.
88-
89-
This library also provides somewhat limited support for PHP 5.3.
90-
While this version lacks the required socket options and constants for listening
91-
on multicast addresses for incoming messages, its underlying socket API is still
92-
[level 1 multicast conformant](http://www.tldp.org/HOWTO/Multicast-HOWTO-2.html#ss2.2).
93-
This means that it can be used for sending outgoing packages to multicast addresses
94-
and receiving incoming unicast responses in return.
95-
9695
## Install
9796

9897
The recommended way to install this library is [through composer](http://getcomposer.org). [New to composer?](http://getcomposer.org/doc/00-intro.md)

0 commit comments

Comments
 (0)