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