Re: Sockets, was Re: [Raw Socket API]. New version separating UDP and TCP interfaces

On Fri, Feb 22, 2013 at 7:06 AM, Marcos Caceres <w3c@marcosc.com> wrote:
> Hi,
> I don't yet have concrete feedback on this API, but from first glance I'm concerned that it seems to deviate quite a bit from Web Sockets (I understand that it has to, because of the different requirements of the protocols). Also, the Node.js community has done a lot of work in creating socket APIs that seem much simpler than the ones proposed (at least it seems so at first glance), such as:
>
> * http://socket.io/
> * https://github.com/LearnBoost/engine.io
> * https://github.com/socketstream/ss-sockjs
> * https://github.com/nodejitsu/nssocket/
> * https://github.com/socketstream/socketstream
>
> See also "npm search socket"
>
> It would be great if we could do a round of collecting data about what APIs are out there, and what developers are using and critically evaluate those. It would suck to reinvent the wheel when there are already good patterns out there that pair client and servers nicely (like socket.io does with its client-side library).

Let me make another plug for the API that we're currently using in
Firefox OS and which was somewhat modeled after the WebSocket API:

http://mxr.mozilla.org/mozilla-central/source/dom/network/interfaces/nsIDOMTCPSocket.idl#29

There are a few things that we expect will need to be changed in this API:
* We should use a real constructor rather than a .open method
* The binaryType API likely needs to be changed to fit the latest
whims of how ArrayBuffers should be used :)
* Buffering might need to be more configurable
* Needs support for startTLS

Additionally we need to add support for incoming connections. This is
something that I don't quite understand with the current API. I would
have expected there to be a static 'listen' function which allowed
registering a callback for incoming connections. This callback would
receive a TCPSocket object. The current setup where you seem to need
to create a TCPSocket object first, and then call bind and/or listen
seems very awkward to me.

> Better still, we should reach out to the developers of the above libraries to review and comment on anything we come up with.

Yes!

> Also, where are the use cases for the raw socket APIs documented?

The use cases that we had for FirefoxOS were:

* An email client which communicates with SMTP, POP3 and IMAP servers
* An irc client which communicates with irc servers.
* Implementing an ssh app.
* Communicating with existing consumer hardware, like internet connected TVs.

For some of these types of hardware we'll likely need higher-level
APIs. But we'll never be able to cover all existing hardware and
software that is out there, so we need a fallback.

/ Jonas

Received on Monday, 25 February 2013 10:32:27 UTC