1d4afb5ceSopenharmony_ci# lws minimal secure streams server raw 2d4afb5ceSopenharmony_ci 3d4afb5ceSopenharmony_ciThe application sets up a raw tcp server on localhost:7681 4d4afb5ceSopenharmony_ci 5d4afb5ceSopenharmony_ciIt does it using Secure Streams... information about how the server should 6d4afb5ceSopenharmony_cioperate is held in JSON policy in main.c 7d4afb5ceSopenharmony_ci 8d4afb5ceSopenharmony_ciConnecting to the server using `echo "hello" | nc --no-shutdown 127.0.0.1 7681` 9d4afb5ceSopenharmony_ciwill send "hello" which is hexdumped to console by the rx function, then 10d4afb5ceSopenharmony_ciwill receive an incrementing message at 100ms intervals. 11d4afb5ceSopenharmony_ci 12d4afb5ceSopenharmony_ciNote there are two incomaptible versions of netcat around, this is from Fedora's 13d4afb5ceSopenharmony_cinmap-ncat, the --no-shutdown is needed to stop it hanging up itself after it 14d4afb5ceSopenharmony_cihas sent its stdin. 15d4afb5ceSopenharmony_ci 16d4afb5ceSopenharmony_ci## build 17d4afb5ceSopenharmony_ci 18d4afb5ceSopenharmony_ci``` 19d4afb5ceSopenharmony_ci $ cmake . && make 20d4afb5ceSopenharmony_ci``` 21d4afb5ceSopenharmony_ci 22d4afb5ceSopenharmony_ci## usage 23d4afb5ceSopenharmony_ci 24d4afb5ceSopenharmony_ciCommandline option|Meaning 25d4afb5ceSopenharmony_ci---|--- 26d4afb5ceSopenharmony_ci-d <loglevel>|Debug verbosity in decimal, eg, -d15 27d4afb5ceSopenharmony_ci 28d4afb5ceSopenharmony_ci``` 29d4afb5ceSopenharmony_ci[2020/07/28 10:25:54:6747] U: LWS Secure Streams Server Raw 30d4afb5ceSopenharmony_ci[2020/07/28 10:25:54:7194] N: LWS: 4.0.99-v4.0.0-247-g58be599aa, loglevel 1031 31d4afb5ceSopenharmony_ci[2020/07/28 10:25:54:7198] N: NET CLI SRV H1 H2 WS MQTT SS-JSON-POL SSPROX ASYNC_DNS IPv6-absent 32d4afb5ceSopenharmony_ci[2020/07/28 10:25:54:9376] N: lws_adopt_descriptor_vhost2: wsi 0x5317d30, vhost system ss_handle (nil) 33d4afb5ceSopenharmony_ci[2020/07/28 10:25:54:9442] N: lws_adopt_descriptor_vhost2: wsi 0x53182c0, vhost system ss_handle (nil) 34d4afb5ceSopenharmony_ci[2020/07/28 10:25:54:9920] N: smd_cb: creating server stream 35d4afb5ceSopenharmony_ci[2020/07/28 10:25:54:9963] N: lws_ss_create: created server myrawserver 36d4afb5ceSopenharmony_ci[2020/07/28 10:26:00:1065] N: secstream_raw: RAW_ADOPT 37d4afb5ceSopenharmony_ci[2020/07/28 10:26:00:1068] N: lws_adopt_descriptor_vhost2: wsi 0x531a6b0, vhost myrawserver ss_handle 0x5319ac0 38d4afb5ceSopenharmony_ci[2020/07/28 10:26:00:1088] U: myss_raw_state: 0x531aad0 LWSSSCS_CREATING, ord 0x0 39d4afb5ceSopenharmony_ci[2020/07/28 10:26:00:1094] U: myss_raw_state: 0x531aad0 LWSSSCS_CONNECTING, ord 0x0 40d4afb5ceSopenharmony_ci[2020/07/28 10:26:00:1096] U: myss_raw_state: 0x531aad0 LWSSSCS_CONNECTED, ord 0x0 41d4afb5ceSopenharmony_ci[2020/07/28 10:26:00:1172] U: myss_raw_rx: len 6, flags: 0 42d4afb5ceSopenharmony_ci[2020/07/28 10:26:02:8516] U: myss_raw_state: 0x531aad0 LWSSSCS_DISCONNECTED, ord 0x0 43d4afb5ceSopenharmony_ci[2020/07/28 10:26:02:8545] U: myss_raw_state: 0x531aad0 LWSSSCS_DESTROYING, ord 0x0 44d4afb5ceSopenharmony_ci^C[2020/07/28 10:26:04:9608] U: myss_raw_state: 0x5319ac0 LWSSSCS_DESTROYING, ord 0x0 45d4afb5ceSopenharmony_ci[2020/07/28 10:26:04:9723] U: Completed: OK 46d4afb5ceSopenharmony_ci``` 47d4afb5ceSopenharmony_ci 48d4afb5ceSopenharmony_ci``` 49d4afb5ceSopenharmony_ci$ echo "hello" | nc --no-shutdown 127.0.0.1 7681 50d4afb5ceSopenharmony_cihello from raw 0 51d4afb5ceSopenharmony_cihello from raw 1 52d4afb5ceSopenharmony_cihello from raw 2 53d4afb5ceSopenharmony_ci... 54d4afb5ceSopenharmony_ci``` 55