Implement a better socket behaviour for TCP sockets