On the server side, it really depends on the implementation, language and API of the websockets library, or you use your implementation.
This description is relevant only for the implementation of RAW Web applications and is not based on the use of any libraries for working with the WebSockets protocol. Libraries such as jWebSockets (Java), SignalR, socket.io and others will have completely different processes for working with WebSockets.
If we are talking about raw implementation in raw sockets, then the process is this:
- TCP- , , . . .Net , , , .
1. , JS: WebSocket (...);
- . TCP , .
- WebSockets , HTTP- - , . , , , - - .
- . , WebSocket.
4b. (), "onopen", "onerror" "onclose" .
- , , . ( ) WebSockets. WebSockets - MESSAGE. , .
- , , TCP. 2 , (2 ) - , , , . . . 2 , . , , TCP. , , ( , ), . , .
- , , , , , "socket.send("... ");".
- , , UTF8, , , , , . , .
- , , , "onmessage" , .
. , , , .
TCP. .
.
WebSockets RFC 6455, , iOS , , .