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

Graceful termination of ReadLoop #48

Closed
RandoMan70 opened this issue Sep 4, 2023 · 4 comments
Closed

Graceful termination of ReadLoop #48

RandoMan70 opened this issue Sep 4, 2023 · 4 comments
Labels
question Further information is requested

Comments

@RandoMan70
Copy link

Something like WriteClose() but really closing connection and terminating ReadLoop?

@lxzan
Copy link
Owner

lxzan commented Sep 4, 2023

Calling WriteClose immediately exits the loop and closes the connection
If you don't want to send a close frame, try socket.NetConn().Close()

@lxzan lxzan added the question Further information is requested label Sep 4, 2023
@lxzan
Copy link
Owner

lxzan commented Sep 4, 2023

Are you worried that WriteClose won't make the loop exit immediately?

@RandoMan70
Copy link
Author

Thank you, NetConn().Close() works fine. I actually found that in my conditions WriteClose() does not exit loop, but I'm using custom Conn over raw sockets.

@lxzan
Copy link
Owner

lxzan commented Sep 4, 2023

I've just committed some code that calls the underlying connection's Close method in WriteClose. You can experience this with this command:

go get -v github.com/lxzan/gws@90819f9bb947a83d073061285be6e3a54c317cd3

There's very little change, and it'll be a while before I put an official tag on it.

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

No branches or pull requests

2 participants