S
Silby
Having finally got a working asynchronous server up (sends and recieves data
fine) i get stuck again.
I'm not quite sure how i can safely disconnect the client. It doesnt really
matter how initiates the disconnect, both sides should be able to do it.
The problem lies in the callback function for reading data, more
specifically, at this point:
bytesRead = handler.EndReceive(AR)
bytesread is an int, handler a socket and AR and IAsyncResult.
When disconnecting it still seems to want to read the termination signals,
but by then the socket is already gone.
Now i currently solve it in a rather crappy manner I catch the error, set
bytesread to a negative value and make sure that when bytesread is negative,
all the remaining code does not get run.
Can someone explain how i could catch a termination signal and cleanly solve
it ?
fine) i get stuck again.
I'm not quite sure how i can safely disconnect the client. It doesnt really
matter how initiates the disconnect, both sides should be able to do it.
The problem lies in the callback function for reading data, more
specifically, at this point:
bytesRead = handler.EndReceive(AR)
bytesread is an int, handler a socket and AR and IAsyncResult.
When disconnecting it still seems to want to read the termination signals,
but by then the socket is already gone.
Now i currently solve it in a rather crappy manner I catch the error, set
bytesread to a negative value and make sure that when bytesread is negative,
all the remaining code does not get run.
Can someone explain how i could catch a termination signal and cleanly solve
it ?