Andy Green | b214977 | 2010-10-31 13:15:56 +0000 | [diff] [blame] | 1 | Using test-server as a quickstart |
| 2 | --------------------------------- |
| 3 | |
Andy Green | a1e3ec0 | 2010-11-08 17:16:50 +0000 | [diff] [blame] | 4 | For a Fedora x86_86 box, the following config line was |
| 5 | needed: |
| 6 | |
| 7 | ./configure --prefix=/usr --libdir=/usr/lib64 --enable-openssl |
| 8 | |
| 9 | otherwise if /usr/local/... and /usr/local/lib are OK then... |
| 10 | |
Andy Green | 3c97469 | 2010-11-08 17:04:09 +0000 | [diff] [blame] | 11 | $ ./configure --enable-openssl |
Andy Green | 05a0a7b | 2010-10-31 17:51:39 +0000 | [diff] [blame] | 12 | $ make |
Andy Green | 7310e9c | 2010-11-01 09:12:17 +0000 | [diff] [blame] | 13 | $ sudo make install |
| 14 | $ libwebsockets-test-server |
Andy Green | b214977 | 2010-10-31 13:15:56 +0000 | [diff] [blame] | 15 | |
| 16 | should be enough to get a test server listening on port 7861. |
| 17 | |
Andy Green | 4739e5c | 2011-01-22 12:51:57 +0000 | [diff] [blame^] | 18 | Testing server with a browser |
| 19 | ----------------------------- |
Andy Green | ed11a02 | 2011-01-20 10:23:50 +0000 | [diff] [blame] | 20 | |
Andy Green | b214977 | 2010-10-31 13:15:56 +0000 | [diff] [blame] | 21 | If you point your browser (eg, Chrome) to |
| 22 | |
| 23 | http://127.0.0.1:7681 |
| 24 | |
Andy Green | 3c97469 | 2010-11-08 17:04:09 +0000 | [diff] [blame] | 25 | It will fetch a script in the form of test.html, and then run the |
Andy Green | 7310e9c | 2010-11-01 09:12:17 +0000 | [diff] [blame] | 26 | script in there on the browser to open a websocket connection. |
| 27 | Incrementing numbers should appear in the browser display. |
Andy Green | b214977 | 2010-10-31 13:15:56 +0000 | [diff] [blame] | 28 | |
Andy Green | ed11a02 | 2011-01-20 10:23:50 +0000 | [diff] [blame] | 29 | Using SSL |
| 30 | --------- |
| 31 | |
Andy Green | 4739e5c | 2011-01-22 12:51:57 +0000 | [diff] [blame^] | 32 | The client side operation does not support SSL yet, but the |
| 33 | server side does. |
| 34 | |
Andy Green | 3c97469 | 2010-11-08 17:04:09 +0000 | [diff] [blame] | 35 | To test it using SSL/WSS, just run the test server with |
| 36 | |
| 37 | $ libwebsockets-test-server --ssl |
| 38 | |
| 39 | and use the URL |
| 40 | |
| 41 | https://127.0.0.1:7681 |
| 42 | |
| 43 | The connection will be entirely encrypted using some generated |
| 44 | certificates that your browser will not accept, since they are |
| 45 | not signed by any real Certificate Authority. Just accept the |
| 46 | certificates in the browser and the connection will proceed |
| 47 | in first https and then websocket wss, acting exactly the |
| 48 | same. |
| 49 | |
Andy Green | b214977 | 2010-10-31 13:15:56 +0000 | [diff] [blame] | 50 | test-server.c is all that is needed to use libwebsockets for |
| 51 | serving both the script html over http and websockets. |
| 52 | |
Andy Green | ed11a02 | 2011-01-20 10:23:50 +0000 | [diff] [blame] | 53 | Forkless operation |
| 54 | ------------------ |
| 55 | |
| 56 | If your target device does not offer fork(), you can use |
| 57 | libwebsockets from your own main loop instead. Use the |
| 58 | configure option --nofork and simply call libwebsocket_service() |
| 59 | from your own main loop as shown in the test app sources. |
| 60 | |
Andy Green | 4739e5c | 2011-01-22 12:51:57 +0000 | [diff] [blame^] | 61 | Testing websocket client support |
| 62 | -------------------------------- |
| 63 | |
| 64 | If you run the test server as described above, you can also |
| 65 | connect to it using the test client as well as a browser. |
| 66 | |
| 67 | $ libwebsockets-test-client localhost |
| 68 | |
| 69 | will by default connect to the test server on localhost:7681 |
| 70 | and print the dumb increment number from the server at the |
| 71 | same time as drawing random circles in the mirror protocol; |
| 72 | if you connect to the test server using a browser at the |
| 73 | same time you will be able to see the circles being drawn. |
| 74 | |
Andy Green | ed11a02 | 2011-01-20 10:23:50 +0000 | [diff] [blame] | 75 | |
| 76 | Websocket version supported |
| 77 | --------------------------- |
| 78 | |
Andy Green | 4739e5c | 2011-01-22 12:51:57 +0000 | [diff] [blame^] | 79 | The websocket client code is 04 version, the server supports |
| 80 | both 00/76 in text mode and 04 dynamically per-connection |
| 81 | depending on the version of the client / browser. |
Andy Green | ed11a02 | 2011-01-20 10:23:50 +0000 | [diff] [blame] | 82 | |
Andy Green | 4739e5c | 2011-01-22 12:51:57 +0000 | [diff] [blame^] | 83 | 2011-01-22 Andy Green <andy@warmcat.com> |
Andy Green | b214977 | 2010-10-31 13:15:56 +0000 | [diff] [blame] | 84 | |