blob: 9a48db2e90ff0d7cf96f77d52f1b8c0523b82aeb [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 Green9293b052011-01-23 17:53:54 +000012$ make clean
Andy Green05a0a7b2010-10-31 17:51:39 +000013$ make
Andy Green7310e9c2010-11-01 09:12:17 +000014$ sudo make install
15$ libwebsockets-test-server
Andy Greenb2149772010-10-31 13:15:56 +000016
17should be enough to get a test server listening on port 7861.
18
Andy Green9293b052011-01-23 17:53:54 +000019There are a couple of other possible configure options
20
21--enable-nofork disables the fork into the background API
22 and removes all references to fork() and
23 pr_ctl() from the sources. Use it if your
24 platform doesn't support forking.
25
26--enable-libcrypto by default libwebsockets uses its own
27 built-in md5 and sha-1 implementation for
28 simplicity. However the libcrypto ones
29 may be faster, and in a distro context it
30 may be highly desirable to use a common
31 library implementation for ease of security
32 upgrades. Give this configure option
33 to disable the built-in ones and force use
34 of the libcrypto (part of openssl) ones.
35
Andy Green4739e5c2011-01-22 12:51:57 +000036Testing server with a browser
37-----------------------------
Andy Greened11a022011-01-20 10:23:50 +000038
Andy Greenb2149772010-10-31 13:15:56 +000039If you point your browser (eg, Chrome) to
40
41 http://127.0.0.1:7681
42
Andy Green3c974692010-11-08 17:04:09 +000043It will fetch a script in the form of test.html, and then run the
Andy Green7310e9c2010-11-01 09:12:17 +000044script in there on the browser to open a websocket connection.
45Incrementing numbers should appear in the browser display.
Andy Greenb2149772010-10-31 13:15:56 +000046
Andy Greened11a022011-01-20 10:23:50 +000047Using SSL
48---------
49
Andy Green4739e5c2011-01-22 12:51:57 +000050The client side operation does not support SSL yet, but the
51server side does.
52
Andy Green3c974692010-11-08 17:04:09 +000053To test it using SSL/WSS, just run the test server with
54
55$ libwebsockets-test-server --ssl
56
57and use the URL
58
59 https://127.0.0.1:7681
60
61The connection will be entirely encrypted using some generated
62certificates that your browser will not accept, since they are
63not signed by any real Certificate Authority. Just accept the
64certificates in the browser and the connection will proceed
65in first https and then websocket wss, acting exactly the
66same.
67
Andy Greenb2149772010-10-31 13:15:56 +000068test-server.c is all that is needed to use libwebsockets for
69serving both the script html over http and websockets.
70
Andy Greened11a022011-01-20 10:23:50 +000071Forkless operation
72------------------
73
74If your target device does not offer fork(), you can use
75libwebsockets from your own main loop instead. Use the
76configure option --nofork and simply call libwebsocket_service()
77from your own main loop as shown in the test app sources.
78
Andy Green4739e5c2011-01-22 12:51:57 +000079Testing websocket client support
80--------------------------------
81
82If you run the test server as described above, you can also
83connect to it using the test client as well as a browser.
84
85$ libwebsockets-test-client localhost
86
87will by default connect to the test server on localhost:7681
88and print the dumb increment number from the server at the
89same time as drawing random circles in the mirror protocol;
90if you connect to the test server using a browser at the
91same time you will be able to see the circles being drawn.
92
Andy Greened11a022011-01-20 10:23:50 +000093
94Websocket version supported
95---------------------------
96
Andy Green4739e5c2011-01-22 12:51:57 +000097The websocket client code is 04 version, the server supports
98both 00/76 in text mode and 04 dynamically per-connection
99depending on the version of the client / browser.
Andy Greened11a022011-01-20 10:23:50 +0000100
Andy Green4739e5c2011-01-22 12:51:57 +00001012011-01-22 Andy Green <andy@warmcat.com>
Andy Greenb2149772010-10-31 13:15:56 +0000102