How to validate a socket descripter
-
Hi Guys, Is there any way to validate a socket descriptor before doing any IO on it? ~ Vikram S
-
Hi Guys, Is there any way to validate a socket descriptor before doing any IO on it? ~ Vikram S
What do you mean by validate, against what criteria?
Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
-
What do you mean by validate, against what criteria?
Unrequited desire is character building. OriginalGriff I'm sitting here giving you a standing ovation - Len Goodman
For example I am holding an client socket connected with some server. The server goes down or network goes down. Before doing any action I want to know is the socket in good state.
-
For example I am holding an client socket connected with some server. The server goes down or network goes down. Before doing any action I want to know is the socket in good state.
Ah, the age old problem. Look, when two asynchronous processes are communicating things can go wrong at any moment. Even if there was a great way for you to check to see if the socket is in a good state, 1/2 microsecond later it could go bad so you'd still have to handle the "bad state" case when you access the socket connection. Just because it was in a good state an instant ago doesn't mean it still is, that's the nature of asynchronous communications and networks. The falicy is expecting orderly things to happen in a disorderly world. Better to concentrate your efforts in dealing with the "error conditions", trying to communicate with the socket and discovering it's in a "bad state" by handling the failure returns, timeouts, etc. Handle the "disorderly shutdown" cases and you'll discover that the "orderly shutdown" cases fall out nicely.
-
For example I am holding an client socket connected with some server. The server goes down or network goes down. Before doing any action I want to know is the socket in good state.