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 | 9293b05 | 2011-01-23 17:53:54 +0000 | [diff] [blame^] | 12 | $ make clean |
Andy Green | 05a0a7b | 2010-10-31 17:51:39 +0000 | [diff] [blame] | 13 | $ make |
Andy Green | 7310e9c | 2010-11-01 09:12:17 +0000 | [diff] [blame] | 14 | $ sudo make install |
| 15 | $ libwebsockets-test-server |
Andy Green | b214977 | 2010-10-31 13:15:56 +0000 | [diff] [blame] | 16 | |
| 17 | should be enough to get a test server listening on port 7861. |
| 18 | |
Andy Green | 9293b05 | 2011-01-23 17:53:54 +0000 | [diff] [blame^] | 19 | There 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 Green | 4739e5c | 2011-01-22 12:51:57 +0000 | [diff] [blame] | 36 | Testing server with a browser |
| 37 | ----------------------------- |
Andy Green | ed11a02 | 2011-01-20 10:23:50 +0000 | [diff] [blame] | 38 | |
Andy Green | b214977 | 2010-10-31 13:15:56 +0000 | [diff] [blame] | 39 | If you point your browser (eg, Chrome) to |
| 40 | |
| 41 | http://127.0.0.1:7681 |
| 42 | |
Andy Green | 3c97469 | 2010-11-08 17:04:09 +0000 | [diff] [blame] | 43 | 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] | 44 | script in there on the browser to open a websocket connection. |
| 45 | Incrementing numbers should appear in the browser display. |
Andy Green | b214977 | 2010-10-31 13:15:56 +0000 | [diff] [blame] | 46 | |
Andy Green | ed11a02 | 2011-01-20 10:23:50 +0000 | [diff] [blame] | 47 | Using SSL |
| 48 | --------- |
| 49 | |
Andy Green | 4739e5c | 2011-01-22 12:51:57 +0000 | [diff] [blame] | 50 | The client side operation does not support SSL yet, but the |
| 51 | server side does. |
| 52 | |
Andy Green | 3c97469 | 2010-11-08 17:04:09 +0000 | [diff] [blame] | 53 | To test it using SSL/WSS, just run the test server with |
| 54 | |
| 55 | $ libwebsockets-test-server --ssl |
| 56 | |
| 57 | and use the URL |
| 58 | |
| 59 | https://127.0.0.1:7681 |
| 60 | |
| 61 | The connection will be entirely encrypted using some generated |
| 62 | certificates that your browser will not accept, since they are |
| 63 | not signed by any real Certificate Authority. Just accept the |
| 64 | certificates in the browser and the connection will proceed |
| 65 | in first https and then websocket wss, acting exactly the |
| 66 | same. |
| 67 | |
Andy Green | b214977 | 2010-10-31 13:15:56 +0000 | [diff] [blame] | 68 | test-server.c is all that is needed to use libwebsockets for |
| 69 | serving both the script html over http and websockets. |
| 70 | |
Andy Green | ed11a02 | 2011-01-20 10:23:50 +0000 | [diff] [blame] | 71 | Forkless operation |
| 72 | ------------------ |
| 73 | |
| 74 | If your target device does not offer fork(), you can use |
| 75 | libwebsockets from your own main loop instead. Use the |
| 76 | configure option --nofork and simply call libwebsocket_service() |
| 77 | from your own main loop as shown in the test app sources. |
| 78 | |
Andy Green | 4739e5c | 2011-01-22 12:51:57 +0000 | [diff] [blame] | 79 | Testing websocket client support |
| 80 | -------------------------------- |
| 81 | |
| 82 | If you run the test server as described above, you can also |
| 83 | connect to it using the test client as well as a browser. |
| 84 | |
| 85 | $ libwebsockets-test-client localhost |
| 86 | |
| 87 | will by default connect to the test server on localhost:7681 |
| 88 | and print the dumb increment number from the server at the |
| 89 | same time as drawing random circles in the mirror protocol; |
| 90 | if you connect to the test server using a browser at the |
| 91 | same time you will be able to see the circles being drawn. |
| 92 | |
Andy Green | ed11a02 | 2011-01-20 10:23:50 +0000 | [diff] [blame] | 93 | |
| 94 | Websocket version supported |
| 95 | --------------------------- |
| 96 | |
Andy Green | 4739e5c | 2011-01-22 12:51:57 +0000 | [diff] [blame] | 97 | The websocket client code is 04 version, the server supports |
| 98 | both 00/76 in text mode and 04 dynamically per-connection |
| 99 | depending on the version of the client / browser. |
Andy Green | ed11a02 | 2011-01-20 10:23:50 +0000 | [diff] [blame] | 100 | |
Andy Green | 4739e5c | 2011-01-22 12:51:57 +0000 | [diff] [blame] | 101 | 2011-01-22 Andy Green <andy@warmcat.com> |
Andy Green | b214977 | 2010-10-31 13:15:56 +0000 | [diff] [blame] | 102 | |