Monday, March 25, 2013

Sockets and/vs http

By design, http should be pretty robust but since we're talking about Java here, that's another totally different story.

The guys that did JWebSocket went out of their way to port the whole implementation to j2me(even though they made some errors with reading the byte 0xff). It's helpful that it maintains a relatively stable socket connection and will throw an Exception caught in the main app just incase a connection is lost or closed.

Current problem while using http(and which has left me at an impasse) is Timeouts(covered here). This(while I might be terribly wrong), I attribute to the fact that every http connection is atomic and involves setting up and tearing a connection instance. Add to that the fact that different j2me CLDC* implementations restrict the number of connections(sometimes to as little as 2) and the darn s60 bug I found, using sockets over http starts to look a bit more interesting.

As an implementation, Badu and the other guys server-side are working on it, but this is how  I would do it:

  • First of all, I'd like to piggy back on the current ws connection
  • To do this, I would have to shape my requests into a json format e.g {"type" : "POST", "content" : {/*JSON object/array of key=>value pairs to represent the parameters*/}}
*CLDC-Connected Limited Device Configuration(where Limited really means LIMITED)

No comments:

Post a Comment