I've posted this question on
stackoverflow, discussed it with some members of the golang community, and I was encouraged to post here.
Problem: I have a secure application and I want to pause/resume accepting network connections, calling `l.Accept()` blocks the thread, thus you can't pause in a single-thread program. You can use goroutines but that still isn't ideal, as the routine would still accept the connection first and only then can close it if you're in "pause" mode.
This could be solved by:
- having a non-blocking, async, `l.Accept()`
- returning a handle to (accepting) goroutine and killing/re-creating it from main thread
- accepting connections in a separate process and communicating over a socket
The 1st one doesn't exist, the 2nd one is not accepted by the language designers, and the 3rd one is unnecessarily complex and prone to break.
This looks like a shortcoming of golang, is it worth discussing further with lang designers?