I have a program that needs to:
- Handle 20 connections. My program will act as client in every connection, each client connecting to a different server.
- Once connected my client should send a request to the server every second and wait for a response. If no request is sent within 9 seconds, the server will time out the client.
- It is unacceptable for one connection to cause problems for the rest of the connections.
- I do not have access to threads and I do not have access to non-blocking sockets. I have a single-threaded program with blocking sockets.
- Edit: The reason I cannot use threads and non blocking sockets is that I am on a non-standard system. I have a single RTOS(Real-Time Operating System) task available.
To solve this, use of select is necessary but I am not sure if it is sufficient.
Initially I connect to all clients. But select can only be used to see if a read or write will block or not, not if a connect will. So when I have connected to say 2 clients and they are all waiting to be served, what if the 3rd does not work, the connection will block causing the first 2 connections to time out as well.
Can this be solved?