• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# lws minimal ws server (threads) + SMP
2
3This demonstrates both independent threads creating content
4as in the -threads example, and multiple service threads
5as in the http-server-smp example (but with ws).
6
7## build
8
9You must first build libwebsockets itself with cmake `-DLWS_MAX_SMP=8`
10or some other number greater than one.
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