V
Vincent Cantin
Hi,
Here is my problem :
I am developing a client/server application. I have my server which only
have 1 thread to process the requests of all the clients. I need that none
of the read it makes from the input streams of the socket to be blocking, so
I am reading the bytes available in the input stream before I do my reads so
I am never in a blocking state.
Now, my problem is that I don't know how to detect when a client close his
socket. I saw on the net that usually the programmers are reading the input
stream or writing the output stream in order to receive an IOException, but
when the client close his socket, the available number of byte in the input
stream of the server doesn't change, and I don't know how to make the
detection.
Do you see the paradox ? I need to call a blocking function if I want to to
detect the close of the socket, but in my server I cannot afford to call a
blocking function.
If someone have a magical way to detect in a non-blocking way when a client
close normally his socket, then I will really be happy to heard it.
Thank you,
Vincent
Here is my problem :
I am developing a client/server application. I have my server which only
have 1 thread to process the requests of all the clients. I need that none
of the read it makes from the input streams of the socket to be blocking, so
I am reading the bytes available in the input stream before I do my reads so
I am never in a blocking state.
Now, my problem is that I don't know how to detect when a client close his
socket. I saw on the net that usually the programmers are reading the input
stream or writing the output stream in order to receive an IOException, but
when the client close his socket, the available number of byte in the input
stream of the server doesn't change, and I don't know how to make the
detection.
Do you see the paradox ? I need to call a blocking function if I want to to
detect the close of the socket, but in my server I cannot afford to call a
blocking function.
If someone have a magical way to detect in a non-blocking way when a client
close normally his socket, then I will really be happy to heard it.
Thank you,
Vincent