Skip to content

Commit 0b21afa

Browse files
committed
Updated readme
1 parent 1094a4c commit 0b21afa

File tree

1 file changed

+10
-52
lines changed

1 file changed

+10
-52
lines changed

README.md

+10-52
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,23 @@
1-
## Websocket Server for Arduino
1+
## Websocket Client and Server for Arduino
22

3-
This is a simple library that implements a Websocket server running on an Arduino. The Websocket specification is a moving target and this implementation is based on a [draft specification][1] which expired i February 2011. But this is the version that has support by a few browsers and so is what's usable now. The protocol will change slightly as indicated by the [current draft][2] into something that looks nicer to your eye, if you're into staring at Request Headers.
4-
5-
The implementation in this library has restrictions as the Arduino platform resources are quite limited. Most notably, the handshake headers are case sensitive while the specification state they should be case _insensitive_, and, after a header field name and it's trailing colon, there **must** be one and only one space before the header value while the specification only "prefers" one space but allows 0-n.
6-
7-
This will most likely not be a problem as current implementations in Safari, Chrome and Firefox formats the request in that particular way. See below for what it looks like.
8-
9-
_Header example:_
10-
11-
Upgrade: WebSocket
12-
Connection: Upgrade
13-
Host: example.com
14-
Origin: http://example.com
15-
Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5
16-
Sec-WebSocket-Key2: 12998 5 Y3 1 .P00
17-
18-
^n:ds[4U
19-
20-
The last line, the somewhat cryptic `^n:ds[4U` is the third key sent by the client, is always 8 bytes long and not terminated by a newline.
21-
22-
_Response example:_
23-
24-
Upgrade: WebSocket
25-
Connection: Upgrade
26-
Sec-WebSocket-Origin: http://example.com
27-
Sec-WebSocket-Location: ws://example.com/demo
28-
Sec-WebSocket-Protocol: sample
29-
30-
8jKS'y:G*Co,Wxa-
31-
32-
The last line is the MD5 Digest, always 16 bytes and not terminated by a newline.
33-
34-
The next version of the specification will get rid of those butt-ugly keys, keeping everything readable. Or at least not looking broken like the keys above.
35-
36-
Other limitations and assumptions in the current implementation:
37-
38-
* The server requires all received data to be UTF-8 only.
39-
* The server only accepts frames starting with 0x00 and ending with 0xFF. That is, the alternative frame definition in the websocket standard with 0xFF followed by specified length, is not supported. (If I got that part of the spec right.)
40-
* The server assumes all data sent to client is UTF-8 only. No encoding is done by the server.
41-
* The server handles incoming frames of limited lengths (default setting is 256). Remember, an Arduino is not an ocean of free memory cells. Don't even think about trying 2^32 - 1...
3+
This is a simple library that implements a Websocket client and server running on an Arduino.
424

435
### Getting started
446

45-
The example websockets.html file should be served from any web server you have access to. Remember to change the ws://... URL in it to your Arduino.
7+
The example WebSocketServer.html file should be served from any web server you have access to. Remember to change the URL in it to your Arduino. The examples are based on using a WiFly wireless card to connect. If you're using ethernet instead you'll need to swap out the client class.
468

479
Install the library to "libraries" folder in your Arduino sketchbook folder. For example, on a mac that's `~/Documents/Arduino/libraries`.
4810

49-
Try one of the examples to ensure that things work.
11+
Try the examples to ensure that things work.
5012

5113
Start playing with your own code!
5214

53-
### The Future
54-
55-
As the Websocket specification matures, the implementations in various browsers will follow and this library will need to change accordingly. I will try to keep up, but I'm not monitoring the Websocket World daily so do file an issue for attention. Or bugs! Or corrections on where I've failed to understand the specification! Or any wish!
56-
57-
_Enjoy!_
58-
59-
Oh by the way, quoting myself:
15+
### Notes
16+
Inside of the WebSocketServer class there is a compiler directive to turn on support for the older "Hixie76" standard. If you don't need it, leave it off as it greatly increases the memory required.
6017

61-
> Don't forget to place a big ***fat*** disclaimer in the README. There is most certainly bugs in the code and I may well have misunderstood some things in the specification which I have only skimmed through and not slept with. So _please_ do not use this code in appliancies where people or pets could get hurt, like space shuttles, dog tread mills and Large Hadron Colliders.
18+
Because of limitations of the current Arduino platform (Uno at the time of this writing), this library does not support messages larger than 65535 characters. In addition, this library only supports single-frame text frames. It currently does not recognize continuation frames, binary frames, or ping/pong frames.
6219

20+
### Credits
21+
Thank you to github user ejeklint for the excellent starting point for this library. From his original Hixie76-only code I was able to add support for RFC 6455 and create the WebSocket client.
6322

64-
[1]: http://www.whatwg.org/specs/web-socket-protocol/ "Protol version implemented here"
65-
[2]: http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol "Latest specification"
23+
- Branden

0 commit comments

Comments
 (0)