Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream in state passiveClose is still considered a connected stream? #318

Open
ArjanKn opened this issue Jul 11, 2022 · 2 comments
Open

Comments

@ArjanKn
Copy link

ArjanKn commented Jul 11, 2022

return s >= ConnectionState.connected && s < ConnectionState.activeClose;

A TCPConnection.connected returns true for state passiveClose. There is no way to react to a server-side-close while waiting for data.
Shouldn;t this be changed so passiveClose is also a 'disconnected'?

@s-ludwig
Copy link
Member

connected describes more or less the "send" direction connection state, whereas the "recv" state should usually be determined by empty. The only difference there is that empty will only reflect the actual state after the read buffer has been fully processed, which is necessary to ensure anything written by the server right before it hangs up is still properly processable.

Depending on the type of protocol, it can also make sense to use waitForData/waitForDataEx instead of empty to support a defined timeout that is different from the general TCP read timeout.

@ArjanKn
Copy link
Author

ArjanKn commented Jul 12, 2022

connected is poorly/bad named. At least the documentation should be made more clear.
The empty => return leastSize == 0. Also not obvious it should/could be used to (enforced) determination of connection state.

The waitForData is currently being used with the connected intended to detect closed by peer which does not work out as expected due to the above.

Why not have full exposure of the connection state through TCPConnection?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants