I've posted this question on stackoverflow
<https://stackoverflow.com/questions/76447195/how-to-suspend-and-resume-accepting-new-connections-in-net-listener>,
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?

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CAN7%3DS7htWfYUQmd3H8GiWoWSaei1qU-FMcpqdyccFkXN1kmsWg%40mail.gmail.com.

Reply via email to