It's correct but it doesn't do anything. The only thing I see incorrect (but only because of knowing what "issues" you experience) is that you read all the data each and every time and that's why you get "SocketSocket" instead of two "Socket" reads. It's because you probably don't understand (or just forgot about it) that TCP is a stream of bytes and is not record-based. The fact that on the sending side you write two "Socket" words separately won't cause the receiving end to read two datagrams containing one "Socket" entry each. And you get 99% of the CPU usage probably because you are dumping the contents of the sockets to the console which is terribly time consuming.
Bookmarks