Jump to content
Fr0sT.Brutal

Suggestion/discussion. Process incoming data when Server has closed connection

Recommended Posts

Faced the issue in my project. I have OnDataAvailable reading and processing data and OnSessionClosed logging the event and doing some other things. And in some cases server sends a response and then immediately closes connection. So I get:

OnDataAvailable

OnDataAvailable

FD_CLOSE that calls OnDataAvailable and then OnSessionClosed

The problem is that in OnDataAvailable I can't tell whether the socket has been closed or not because FCloseInvoked flag is set to True only after DataAvailable loop.

I suggest (if that won't harm or change behavior) to set FCloseInvoked flag before DataAvailable loop and publish it as read-only property so that a user could distinguish whether he can expect some more data or not.

For now I had to call processing method from OnSessionClosed as well.

Share this post


Link to post

I don't see any problem with your proposed change, but don't see any great benefit either, the connection might close without OnDataAvailable being called so you still need processing in OnSessionClosed.  Or am I missing something?

 

Angus

 

Share this post


Link to post

Angus, I have wsoReceiveLoop option set and before calling OnSessionClosed OnDataAvailable is being called anyway.

In current state processing code should be extracted to separate method and called from both OnSessionClosed and OnDataAvailable, moreover it is likely to require SocketClosed parameter to decide whether there will be no data anymore or it could expect some.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×