LearnBoost/socket.io — Issue #680: Support binary framing and transport
Author: adammw
Created: 2011-12-09 06:31:19+00:00
State: open

Hi, I've had two ideas that I've been thinking of to enable sending binary with socket.io that I would like to get feedback on:

Firstly, the idea of supporting binary content by using a new flag and new message type 'binary' . This allows socket.io to handle the binary content in an abstract manner between endpoints, for example using base64 encoding over the current transport mechanisms, or if supported by the transport, using binary framing (see below). Ideally, I'd like it to optionally support/specify an event, because otherwise separating binary messages would require different endpoint identifiers.

Secondly, extending on the first idea, is to introduce a binary framing mechanism for sending data over supported binary transports (e.g. binary websockets, flashsockets, XHR2?) to reduce overall overhead and remove the need to base64 encode and decode binary data at either end.

Thirdly, the standard .send and .emit should automatically set the binary flag if you pass it an ArrayBuffer or (node-only) Buffer.

I was going to draw up also a proposal of the framing format, but it looks like most of the identifiers are variable-length, so I'm not sure of how much space to give them. But looking at [socket.io-spec](https://github.com/LearnBoost/socket.io-spec) it would need to contain:

* Message Type
* Message ID
* Message Endpoint
* Type-dependant data