blob: 811e0a68ce51f62f0c05b1c242b950713644e048 [file] [log] [blame]
Andy Greenb2149772010-10-31 13:15:56 +00001Using test-server as a quickstart
2---------------------------------
3
Andy Greena1e3ec02010-11-08 17:16:50 +00004For a Fedora x86_86 box, the following config line was
5needed:
6
7./configure --prefix=/usr --libdir=/usr/lib64 --enable-openssl
8
9otherwise if /usr/local/... and /usr/local/lib are OK then...
10
Andy Green3c974692010-11-08 17:04:09 +000011$ ./configure --enable-openssl
Andy Green05a0a7b2010-10-31 17:51:39 +000012$ make
Andy Green7310e9c2010-11-01 09:12:17 +000013$ sudo make install
14$ libwebsockets-test-server
Andy Greenb2149772010-10-31 13:15:56 +000015
16should be enough to get a test server listening on port 7861.
17
Andy Green4739e5c2011-01-22 12:51:57 +000018Testing server with a browser
19-----------------------------
Andy Greened11a022011-01-20 10:23:50 +000020
Andy Greenb2149772010-10-31 13:15:56 +000021If you point your browser (eg, Chrome) to
22
23 http://127.0.0.1:7681
24
Andy Green3c974692010-11-08 17:04:09 +000025It will fetch a script in the form of test.html, and then run the
Andy Green7310e9c2010-11-01 09:12:17 +000026script in there on the browser to open a websocket connection.
27Incrementing numbers should appear in the browser display.
Andy Greenb2149772010-10-31 13:15:56 +000028
Andy Greened11a022011-01-20 10:23:50 +000029Using SSL
30---------
31
Andy Green4739e5c2011-01-22 12:51:57 +000032The client side operation does not support SSL yet, but the
33server side does.
34
Andy Green3c974692010-11-08 17:04:09 +000035To test it using SSL/WSS, just run the test server with
36
37$ libwebsockets-test-server --ssl
38
39and use the URL
40
41 https://127.0.0.1:7681
42
43The connection will be entirely encrypted using some generated
44certificates that your browser will not accept, since they are
45not signed by any real Certificate Authority. Just accept the
46certificates in the browser and the connection will proceed
47in first https and then websocket wss, acting exactly the
48same.
49
Andy Greenb2149772010-10-31 13:15:56 +000050test-server.c is all that is needed to use libwebsockets for
51serving both the script html over http and websockets.
52
Andy Greened11a022011-01-20 10:23:50 +000053Forkless operation
54------------------
55
56If your target device does not offer fork(), you can use
57libwebsockets from your own main loop instead. Use the
58configure option --nofork and simply call libwebsocket_service()
59from your own main loop as shown in the test app sources.
60
Andy Green4739e5c2011-01-22 12:51:57 +000061Testing websocket client support
62--------------------------------
63
64If you run the test server as described above, you can also
65connect to it using the test client as well as a browser.
66
67$ libwebsockets-test-client localhost
68
69will by default connect to the test server on localhost:7681
70and print the dumb increment number from the server at the
71same time as drawing random circles in the mirror protocol;
72if you connect to the test server using a browser at the
73same time you will be able to see the circles being drawn.
74
Andy Greened11a022011-01-20 10:23:50 +000075
76Websocket version supported
77---------------------------
78
Andy Green4739e5c2011-01-22 12:51:57 +000079The websocket client code is 04 version, the server supports
80both 00/76 in text mode and 04 dynamically per-connection
81depending on the version of the client / browser.
Andy Greened11a022011-01-20 10:23:50 +000082
Andy Green4739e5c2011-01-22 12:51:57 +0000832011-01-22 Andy Green <andy@warmcat.com>
Andy Greenb2149772010-10-31 13:15:56 +000084