Fr0sT.Brutal 900 Posted July 26, 2019 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
Angus Robertson 574 Posted July 26, 2019 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
Fr0sT.Brutal 900 Posted August 8, 2019 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