Sending and receiving of messages using TCP and WebSockets