README.md
1# lws minimal ws server
2
3This demonstrates adopting a file descriptor into the lws event
4loop. The filepath to open and adopt is given as an argument to the example app, eg
5
6```
7 $ ./lws-minimal-raw-file <file>
8```
9
10On a Linux system, some example files for testing might be
11
12 - /proc/self/fd/0 (stdin)
13 - /dev/ttyUSB0 (a USB <-> serial converter)
14 - /dev/input/event<n> (needs root... input device events)
15
16The example application opens the file in the protocol init
17handler, and hexdumps data from the file to the lws log
18as it becomes available.
19
20This isn't very useful standalone as shown here for clarity, but you can
21freely combine raw file descriptor adoption with other lws server
22and client features.
23
24Becuase raw file events have their own callback reasons, the handlers can
25be integrated in a single protocol that also handles http and ws
26server and client callbacks without conflict.
27
28## build
29
30```
31 $ cmake . && make
32```
33
34## usage
35
36```
37 $ ./lws-minimal-raw-file /proc/self/fd/0
38[2018/03/22 10:48:53:9709] USER: LWS minimal raw file
39[2018/03/22 10:48:53:9876] NOTICE: Creating Vhost 'default' port -2, 1 protocols, IPv6 off
40[2018/03/22 10:48:55:0037] NOTICE: LWS_CALLBACK_RAW_ADOPT_FILE
41
42[2018/03/22 10:48:55:9370] NOTICE: LWS_CALLBACK_RAW_RX_FILE
43[2018/03/22 10:48:55:9377] NOTICE:
44[2018/03/22 10:48:55:9408] NOTICE: 0000: 0A .
45
46```
47
48The example logs above show the result of typing the Enter key.
49