Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Sure, but what if you want to shut that goroutine down later on?

The best solution that I've found is to just close the connection, the .Recv() will error out immediately.



What other solution would you want? You could use `SetDeadline` if you like. But closing the connection seems reasonable too.

I think you're framing the problem wrong. You're not asking to shutdown a goroutine, you're asking "How do I abort from a synchronous read from a network connection that is blocked?"


Don't get too hung up on that, it was the least of the problems. Closing the connection works fine, it's just a bit unorthodox. The basic structure of the problem was much more problematic to implement.


Yes, that is afaik the only way to abort a synchronous function call such as TCPConn.Read().




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: