As many developers are painfully aware, there is no way to access a raw socket from within a pure webOS application, because the necessary system services are not yet provided.

I wondered how one might implement a socket in the heavily callback-driven model of the webOS environment. I've made a first stab at it, and it seems to work pretty well. The sockets themselves are managed using a Java service, which provides facilities for creating server and client sockets, reading and writing to/from them, and closing them.

This Java service is paired with a JavaScript helper object that simplifies the common operations, so that those using the socket service don't have to worry about the details of the system service if they don't want to.

I made a bit of progress with this, but it's come to a halt. So rather than having it stagnate on my hard drive, I've made it available on Google Code. It's not quite ready for production, but all that's lacking is polish, to allow better management of currently open sockets, and to change the reading model used (for example, to enable a readline mode).

The code is available here:
osj-sockets - Project Hosting on Google Code

Happy hacking!