File tree Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Expand file tree Collapse file tree 1 file changed +45
-0
lines changed Original file line number Diff line number Diff line change
1
+ # clue/datagram
2
+
3
+ UDP datagram socket client and server for reactphp
4
+
5
+ ## Quickstart example
6
+
7
+ Once [ installed] ( #install ) , you can use the following code to connect to an UDP server listening on
8
+ ` localhost:1234 ` and send and receive UDP datagrams:
9
+
10
+ ``` php
11
+ $loop = React\EventLoop\Factory::create();
12
+
13
+ $factory = new Datagram\Factory($loop);
14
+
15
+ $factory->createClient('localhost', 1234)->then(function (Datagram\Socket $client) use ($loop) {
16
+ $client->send('first');
17
+
18
+ $client->on('message', function($message, $serverAddress, $client) {
19
+ echo 'received "' . $message . '" from ' . $serverAddress. PHP_EOL;
20
+ });
21
+ });
22
+
23
+ $loop->run();
24
+ ```
25
+
26
+ ## Usage
27
+
28
+ This library's API is modelled after node.js's API for
29
+ [ UDP / Datagram Sockets (dgram.Socket)] ( http://nodejs.org/api/dgram.html ) .
30
+
31
+ ## Install
32
+
33
+ The recommended way to install this library is [ through composer] ( http://getcomposer.org ) . [ New to composer?] ( http://getcomposer.org/doc/00-intro.md )
34
+
35
+ ``` JSON
36
+ {
37
+ "require" : {
38
+ "clue/datagram" : " dev-master"
39
+ }
40
+ }
41
+ ```
42
+
43
+ ## License
44
+
45
+ MIT
You can’t perform that action at this time.
0 commit comments