mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-30 00:00:16 +01:00
84 lines
2.4 KiB
Text
84 lines
2.4 KiB
Text
Using test-server as a quickstart
|
|
---------------------------------
|
|
|
|
For a Fedora x86_86 box, the following config line was
|
|
needed:
|
|
|
|
./configure --prefix=/usr --libdir=/usr/lib64 --enable-openssl
|
|
|
|
otherwise if /usr/local/... and /usr/local/lib are OK then...
|
|
|
|
$ ./configure --enable-openssl
|
|
$ make
|
|
$ sudo make install
|
|
$ libwebsockets-test-server
|
|
|
|
should be enough to get a test server listening on port 7861.
|
|
|
|
Testing server with a browser
|
|
-----------------------------
|
|
|
|
If you point your browser (eg, Chrome) to
|
|
|
|
http://127.0.0.1:7681
|
|
|
|
It will fetch a script in the form of test.html, and then run the
|
|
script in there on the browser to open a websocket connection.
|
|
Incrementing numbers should appear in the browser display.
|
|
|
|
Using SSL
|
|
---------
|
|
|
|
The client side operation does not support SSL yet, but the
|
|
server side does.
|
|
|
|
To test it using SSL/WSS, just run the test server with
|
|
|
|
$ libwebsockets-test-server --ssl
|
|
|
|
and use the URL
|
|
|
|
https://127.0.0.1:7681
|
|
|
|
The connection will be entirely encrypted using some generated
|
|
certificates that your browser will not accept, since they are
|
|
not signed by any real Certificate Authority. Just accept the
|
|
certificates in the browser and the connection will proceed
|
|
in first https and then websocket wss, acting exactly the
|
|
same.
|
|
|
|
test-server.c is all that is needed to use libwebsockets for
|
|
serving both the script html over http and websockets.
|
|
|
|
Forkless operation
|
|
------------------
|
|
|
|
If your target device does not offer fork(), you can use
|
|
libwebsockets from your own main loop instead. Use the
|
|
configure option --nofork and simply call libwebsocket_service()
|
|
from your own main loop as shown in the test app sources.
|
|
|
|
Testing websocket client support
|
|
--------------------------------
|
|
|
|
If you run the test server as described above, you can also
|
|
connect to it using the test client as well as a browser.
|
|
|
|
$ libwebsockets-test-client localhost
|
|
|
|
will by default connect to the test server on localhost:7681
|
|
and print the dumb increment number from the server at the
|
|
same time as drawing random circles in the mirror protocol;
|
|
if you connect to the test server using a browser at the
|
|
same time you will be able to see the circles being drawn.
|
|
|
|
|
|
Websocket version supported
|
|
---------------------------
|
|
|
|
The websocket client code is 04 version, the server supports
|
|
both 00/76 in text mode and 04 dynamically per-connection
|
|
depending on the version of the client / browser.
|
|
|
|
2011-01-22 Andy Green <andy@warmcat.com>
|
|
|