Skip to content

Commit c45d936

Browse files
committed
Update README.md
1 parent a9329f4 commit c45d936

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,45 @@ $loop->run();
3434

3535
See also the [examples](examples).
3636

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.
75+
3776
## Description
3877

3978
[PHP 5.4 added support](http://php.net/manual/en/migration54.global-constants.php)

0 commit comments

Comments
 (0)