I have a some questions in understanding websocket communication. AFAIU, in client side, it works like this:
So from client perspective its clear. But from the server perspective how the flow goes (as above for client) and what is exactly mean by a websocket server process and what is exactly when we mean the communication happens on TCP and how do we check that (my aplologies if the question is very basic)
Can somebody please explain. Thanks in advannce
On server side it is really depends on implementation, language and API of websockets library or you own implementation you use.
This description is actual only for RAW implementation of WebSockets and is not based on use of any libraries to work with WebSockets protocol. Libraries, such as jWebSockets (Java), SignalR, socket.io and others will have absolutely another processes to work with WebSockets.
If we are talking about raw implementation on raw sockets, so process is like that:
Client will never receive part of data, or unordered data. It will always receive packets in order you sent, and always as you sent. Server might receive data partially based on low level TCP layer processes. But will receive always ordered.
This protocol is Reliable and Ordered.
Most popular specification of WebSockets protocol RFC 6455 , bear in mind that iOS uses another specification and they might not be cross-compatible what means that you need to create another handshake functionality and data framing specifically for different protocol implementations.
After handshake is done, you can receive and send messages. Messages are dataframed (not raw) based on WebSockets protocol. And WebSockets are MESSAGE based protocol. So you have to make sure you read specific amount of message data before you proceed data for logical processing.
Here some more informations to this:
So, the server can fragment the messages in multiple WebSocket frames which are send to the client.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.