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:
- One communication thread to communicate with the server, to read the socket.
- One data processing thread to process what the communication thread received.