Best programming practices for multiple connections
I am building a Client-Server application which I want it to be portable between Linux and Windows. So here is the idea:
1. The server deamon gets installed and run on multiple computers.
2. Then the client program connects to all of these remote machines and obtains couple of data structures and then closes the connection.
Now, I want to be able to create the client program more like a desktop applet and run constantly, but it will connect to the servers at predefined delay, like once every 5 minutes.
I am curious what would be the best way to do this? Upon testing of the first prototype, I am seeing that if a server does not respond immediately, due to network congestion, the client freezes waiting for connection to be established or data to be received. This essentially stops from making subsequent connections to the other servers and getting data.
How can I avoid stalling the client if one of the connections fails? What would be recommended "refresh"? 60 seconds, 5 minutes?
Any ideas and suggestions would be appreciated. Code examples would be entertained in my testing.
Thanks in advance!