I'm currently writing a program that communicates with a server over TCP sockets. I originally planned for the communication to include a message confirming successful communication at the end of correspondence. Either the server and the client would wait for a response after each communication, depending on who initiated the message. However, I later read that a first step in optimizing socket communications is removing unnecessary correspondence, as each message sent has a small overhead while waiting for a response. So I decided to remove the confirmation messages.
However, those confirmation messages were my easiest way of inserting error messages. What is the best method of sending errors over such a Socket system? Am I trying to optimize prematurely?
The server would be on a remote device with a potentially high ping. The requests generally come in large groups, but each request is in reality individual and can be called out of context. It totally depends on user interaction. Therefore, I cannot know how many requests will be made. It's not easy for the client to figure out when the user is done requesting information as well. I had thought of sending a single confirmation method after a group of requests, but the previous sentence makes that impossible.
I am currently using Java for both ends of this program.