Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ac000/websocket_demo

A demo of WebSockets in C
https://github.com/ac000/websocket_demo

c websocket websocket-protocol websocket-server websockets

Last synced: 7 days ago
JSON representation

A demo of WebSockets in C

Awesome Lists containing this project

README

        

This is a simple demonstration of WebSockets in C. It simply consists of a
server and a HTML page.

After it gets a connection, every two seconds (default) it will send
the hostname, uptime and rx & tx bytes of the system running the server
(can be the same as the client).

Build the server (make), run it (non-root), then load the HTML page
into a browser. You should then see a simple page showing the above
information updating every two seconds. Change the interface to show
stats for and adjust the frequency of updates using the 'spinner' widget.

Really simple, just shows the basics of what's needed for two way
communications.

The WebSocket protocol is defined here: http://tools.ietf.org/html/rfc6455

It also demonstrates the use of epoll(7) to handle multiple connections
in a single process.

It will also make use of libseccomp (if installed) to constrain what system
calls can be used once up and running. This really just serves as a
demonstration.

It also implements WebSockets over TLS (wss://), this can be enabled by
passing 'tls' to the websocket_demo command. And by using
wss://localhost:1976/ as the websocket connection string in
websocket_demo.html

You will also need a TLS certificate and key (can be self made, required
some faffing about in Firefox to get it to work) and specify them in the
the TLS_CERT & TLS_KEY variables in websocket_demo.c

Licensed under the MIT license, see MIT-LICENSE.txt