Working version with TCP sockets and Websockets