1d4afb5ceSopenharmony_ci# lws minimal raw netcat
2d4afb5ceSopenharmony_ci
3d4afb5ceSopenharmony_ciThis example shows to to create a "netcat" that copies its stdin to
4d4afb5ceSopenharmony_cia remote socket and prints what is returned in stdout.
5d4afb5ceSopenharmony_ci
6d4afb5ceSopenharmony_ciIt has some advantage over the real netcat, it will wait 1s after stdin closes
7d4afb5ceSopenharmony_cito print results that are in flight.
8d4afb5ceSopenharmony_ci
9d4afb5ceSopenharmony_ci## build
10d4afb5ceSopenharmony_ci
11d4afb5ceSopenharmony_ci```
12d4afb5ceSopenharmony_ci $ cmake . && make
13d4afb5ceSopenharmony_ci```
14d4afb5ceSopenharmony_ci
15d4afb5ceSopenharmony_ci## usage
16d4afb5ceSopenharmony_ci
17d4afb5ceSopenharmony_ci```
18d4afb5ceSopenharmony_ci $ echo -e -n "GET / http/1.1\r\n\r\n"| ./lws-minimal-raw-netcat
19d4afb5ceSopenharmony_ci[2018/05/02 08:53:53:2665] USER: LWS minimal raw netcat [--server ip] [--port port]
20d4afb5ceSopenharmony_ci[2018/05/02 08:53:53:2667] NOTICE: Creating Vhost 'default' (no listener), 1 protocols, IPv6 off
21d4afb5ceSopenharmony_ci[2018/05/02 08:53:53:2703] USER: Starting connect...
22d4afb5ceSopenharmony_ci[2018/05/02 08:53:53:5644] USER: Connected to libwebsockets.org:80...
23d4afb5ceSopenharmony_ci[2018/05/02 08:53:53:5645] USER: LWS_CALLBACK_RAW_ADOPT
24d4afb5ceSopenharmony_ci[2018/05/02 08:53:53:5645] USER: LWS_CALLBACK_RAW_ADOPT_FILE
25d4afb5ceSopenharmony_ci[2018/05/02 08:53:53:5646] USER: LWS_CALLBACK_RAW_RX_FILE
26d4afb5ceSopenharmony_ci[2018/05/02 08:53:53:5646] USER: LWS_CALLBACK_RAW_CLOSE_FILE
27d4afb5ceSopenharmony_ci[2018/05/02 08:53:53:8600] USER: LWS_CALLBACK_RAW_RX (186)
28d4afb5ceSopenharmony_ciHTTP/1.1 301 Redirect
29d4afb5ceSopenharmony_ciserver: lwsws
30d4afb5ceSopenharmony_ciStrict-Transport-Security: max-age=15768000 ; includeSubDomains
31d4afb5ceSopenharmony_cilocation: https://libwebsockets.org
32d4afb5ceSopenharmony_cicontent-type: text/html
33d4afb5ceSopenharmony_cicontent-length: 0
34d4afb5ceSopenharmony_ci
35d4afb5ceSopenharmony_ci```
36d4afb5ceSopenharmony_ci
37d4afb5ceSopenharmony_ciNote the example does everything itself, after 5s idle the remote server closes the connection
38d4afb5ceSopenharmony_ciafter which the example continues until you ^C it.
39