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
+39Lines changed: 39 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,45 @@ $loop->run();
34
34
35
35
See also the [examples](examples).
36
36
37
+
## Usage
38
+
39
+
### Factory
40
+
41
+
The `Factory` is responsible for creating your [`Socket`](#socket) instances.
42
+
It also registers everything with the main [`EventLoop`](https://github.com/reactphp/event-loop#usage).
43
+
44
+
```php
45
+
$loop = React\EventLoop\Factory::create();
46
+
$factory = new Factory($loop);
47
+
```
48
+
49
+
#### createSender()
50
+
51
+
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.
52
+
53
+
#### createReceiver()
54
+
55
+
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.
56
+
57
+
### Socket
58
+
59
+
The [`Factory`](#factory) creates instances of the `React\Datagram\Socket` class from the [react/datagram](https://github.com/reactphp/datagram) package.
60
+
61
+
```php
62
+
$socket->send($message, $address);
63
+
64
+
$socket->on('message', function ($message, $address) { });
65
+
$socket->on('close', function() { });
66
+
67
+
$socket->pause();
68
+
$socket->resume();
69
+
70
+
$socket->end();
71
+
$socket->close();
72
+
```
73
+
74
+
Please refer to the [datagram documentation](https://github.com/reactphp/datagram#usage) for more details.
0 commit comments