What makes it a real websocket client instead of just a straight socket client? I see that it constructs the HTTP request and I’m wondering what is actually the formal “definition” of a websocket vs a normal Java socket.
https://github.com/koush/android-websockets/blob/master/src/com/codebutler/android_websockets/WebSocketClient.java What makes it a real websocket client instead of just a straight socket
Share
The WebSocket protocol is defined by IETF 6455.
The koush/android-websockets project implements the IETF 6455 version of the WebSocket protocol.
A WebSocket connection starts with an HTTP compatible handshake that allows it to more easily integrate with existing web infrastructure. It also gives it secure cross-origin capability.
Once the connection is established, the WebSocket connection is full-duplex bi-directional connection (unlike an HTTP long-poll for example). However, the connection is not a raw socket even at this point. WebSocket is message based (rather than streaming like the underlying TCP layer) so it required framing of the data to indicate message boundaries. Each WebSocket frame has at least 2 bytes of header which indicates the length of the frame, whether it is the final frame of a message or a continuation, whether the data is UTF-8 or raw binary, etc.
In addition, client (browser) to server WebSocket frames are masked using a simple running XOR in order to avoid a theoretical vulnerability in web intermediaries (proxies, caches, etc).