Here is what I need to do: Server controls limit number of socket connections at one time. If available, client can connect, if server connections beyond the limit, new client is rejected IMMEDIATELY with specific exception message. When server connections are available again, new client's request will be handled as normal. From java.net package, I did not find any API so far, any socket expert's advises? Thx!
Joined: Feb 12, 2002
Hi, I think u can put a counter in Server program. Everytime, client connects to the server, the counter will be incremented. As soon as it reaches the configured value, pass the message to the client saying No more connections available. This will be one solution since as u said, there is no API. Regards Nayan.
Joined: Jan 08, 2003
Thank you for the response. The 2 major drawbacks are: 1. Client has to be blocked at socket input stream to read something from server every time. 2. If there are tens of or hundreds of concurrent users making requests and no available seats, then the server has send tens of hundreds short messages to notify the clients. I am wondering why socket API does not have reject(Object obj) method like, since it has accept method. It does not make sense. Maybe, all underlying OS network C interface does not support "reject" historically.