Subject: [hybi] libwebsockets C library SSL client connections and websocket ping

From: Andy Green <[email-masked]>
Date: Thu, 27 Jan 2011 20:34:18 +0000

Hi -

libwebsockets

http://git.warmcat.com/cgi-bin/cgit/libwebsockets/

now supports SSL client connections as well as SSL server connections, 
along with plain versions of each; one context and per-protocol callback 
can handle both client and server connections in a single polling loop call.

It's now a fairly complete protocol-version-independent implementation 
of both client and server websockets in a very small footprint; with 
openssl configured off there are no dependencies outside libc.

It also introduces a websocket ping utility which can work via 04 PING 
and PONG control packets up to 125 payload length, or via BINARY 
payloads up to 4096 with the help of a server protocol that performs an 
echo (it defaults to using the lws-mirror-protocol supported by the 
libwebsockets test server).  Either way before any kind of frame can be 
sent, even PING that doesn't need cooperation from the protocol, the 
handshake must complete with a protocol acceptable to the server, so it 
can be set from the commandline.

$ libwebsockets-test-ping localhost
handshake OK for protocol lws-mirror-protocol
Websocket PING localhost.localdomain (127.0.0.1) 64 bytes of data.
64 bytes from localhost: req=1 time=0.1ms
64 bytes from localhost: req=2 time=0.1ms
64 bytes from localhost: req=3 time=0.1ms
64 bytes from localhost: req=4 time=0.2ms
64 bytes from localhost: req=5 time=0.1ms
64 bytes from localhost: req=6 time=0.2ms
64 bytes from localhost: req=7 time=0.2ms
64 bytes from localhost: req=8 time=0.1ms
^C
--- localhost.localdomain websocket ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 7458ms
rtt min/avg/max = 0.110/0.185/0.218 ms
$

Like normal ping you can set the interval, size and floodping display, 
and get stats at the end, and it handles out-of-order and delayed and 
duplicated replies.

-Andy