• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# lws minimal ws client
2
3This connects to libwebsockets.org using the dumb-increment-protocol.
4
5It demonstrates how to use the connection retry and backoff stuff in lws.
6
7## build
8
9```
10 $ cmake . && make
11```
12
13## Commandline Options
14
15Option|Meaning
16---|---
17-d|Set logging verbosity
18-s|Use a specific server instead of libwebsockets.org, eg `--server localhost`.  Implies LCCSCF_ALLOW_SELFSIGNED
19-p|Use a specific port instead of 443, eg `--port 7681`
20-j|Allow selfsigned tls cert
21-k|Allow insecure certs
22-m|Skip server hostname check
23-n|Skip tls usage
24-e|Allow expired certs
25--protocol|Use a specific ws subprotocol rather than dumb-increment-protocol, eg, `--protocol myprotocol`
26
27
28## usage
29
30Just run it, it will connect to libwebsockets.org and spew incrementing numbers
31sent by the server at 20Hz
32
33```
34 $ ./lws-minimal-ws-client
35[2020/01/22 05:38:47:3409] U: LWS minimal ws client
36[2020/01/22 05:38:47:4456] N: Loading client CA for verification ./libwebsockets.org.cer
37[2020/01/22 05:38:48:1649] U: callback_minimal: established
38[2020/01/22 05:38:48:1739] N:
39[2020/01/22 05:38:48:1763] N: 0000: 30                                                 0
40[2020/01/22 05:38:48:1765] N:
41
42...
43```
44
45To test against the lws test server instead of libwebsockets.org, run the test
46server as
47
48```
49$ libwebsockets-test-server -s
50```
51
52and run this test app with
53
54```
55$ ./lws-minimal-ws-client -s localhost -p 7681 -j
56```
57
58You can kill and restart the server to confirm the client connection is re-
59established if done within the backoff period.
60