in reply to Sockets and Output

To improve performance and to make the structure of your application more clear, I would suggest you to consider multi-threading.

For example on the client side, it is better to have at least two threads running:
  1. One communication thread to communicate with the server, to read the socket.
  2. One data processing thread to process what the communication thread received.