• Home
Name Date Size #Lines LOC

..--

mount-origin/12-May-2024-210184

CMakeLists.txtD12-May-20241.5 KiB4535

README.mdD12-May-20241.3 KiB4027

minimal-ws-server.cD12-May-20245.4 KiB205130

protocol_lws_minimal.cD12-May-20248.1 KiB322205

README.md

1# lws minimal ws server (threads) + SMP
2
3This demonstrates both independent threads creating content as in the
4-threads example, multiple service threads as in the http-server-smp
5example (but with ws), and using the foreign libuv loop.
6
7## build
8
9You must first build libwebsockets itself with cmake `-DLWS_MAX_SMP=8`
10or some other number greater than one, as well as `-DLWS_WITH_LIBUV=1`
11
12```
13 $ cmake . && make
14```
15
16Pthreads is required on your system.
17
18## usage
19
20```
21 $ ./lws-minimal-ws-server-threads-smp
22[2019/01/28 06:59:17:4217] USER: LWS minimal ws server + threads + smp | visit http://localhost:7681
23[2019/01/28 06:59:17:4219] NOTICE:   Service threads: 2
24[2019/01/28 06:59:17:4220] NOTICE: LWS_CALLBACK_EVENT_WAIT_CANCELLED in svc tid 0x7fec48af8700
25[2019/01/28 06:59:17:4220] NOTICE: LWS_CALLBACK_EVENT_WAIT_CANCELLED in svc tid 0x7fec48af8700
26...
27```
28
29Visit http://localhost:7681 on multiple browser windows.  You may need to open
304 before the second service thread is used (check "svc tid" in the browser output).
31
32Two lws service threads are started.
33
34Two separate asynchronous threads generate strings and add them to a ringbuffer,
35signalling all lws service threads to send new entries to all the browser windows.
36
37This demonstrates how to safely manage asynchronously generated content
38and hook it up to the lws service threads.
39
40