1

There is a javascript code residing in my Android app's webkit container. This code makes use of WebSockets to communicate with the server. The same JS code works in other platforms such as iOS, but in Android 2.3, it doesn't. I read somewhere that the webkit in Android does not support WebSockets, and support will come only in Jelly Bean onwards.

In view of this, I need to provide a wrapper from the native layer (in Java) making use of plain sockets. From the little I know about sockets, it seems straightforward to support the usual APIs such as open(), send(), receive(), etc.

Is there anything else I need to know that the WebSocket protocol needs, which I will need to provide from the wrapper code? After all, the server talks to the client (my android app) as if it is a WebSocket, and not a native socket.

Some notes to consider: a) I cannot make use of any third-party library - it will have to be developed in-house. b) There will not be any binary data transferred; only text.

Thanks,
Rajath

asked Sep 14, 2012 at 6:46

1 Answer 1

1

Websockets are not raw sockets, they require an initial handshake then simple per-message framing. See the protocol spec for details. The sections on handshake and data framing will be most relevant.

I know you said you can't use third party libraries but be aware that projects like Java-Websocket might be interesting to you. It's liberally licensed so suitable for inclusion in any closed source app. Or you might find it useful as a reference while debugging your own code.

answered Sep 14, 2012 at 8:30
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. I'll go through the links you you have mentioned
the spec links you sent were very useful, especially to see that it involved some work. Finally, we went with the Java-Websocket library that you mention. Thanks again.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.