On Fri, Feb 9, 2024 at 2:10 PM Ian Lance Taylor <i...@golang.org> wrote:

> On Fri, Feb 9, 2024 at 11:57 AM Kurtis Rader <kra...@skepticism.us> wrote:
> >
> > The connect() syscall is normally blocking. It doesn't return until the
> connection is established or an error occurs. It can be made non-blocking
> by putting the file-descriptor into non-blocking mode before the connect()
> call. However, that then requires either an async callback or another
> syscall to check whether the connection was established or an error
> occurred. Neither approach is idiomatic Go.
>
> That is true, but the Go standard library's net package does use
> non-blocking calls to connect internally when implementing net.Dial
> and friends.
>
> I don't have any problem running the original program on Linux 6.5.13.
>

Yes, I realized after my previous reply that Go could obviously use
non-blocking connect() calls coupled with select(), poll(), or similar
mechanisms to wakeup a goroutine blocked waiting for a net.Dial() (or
equivalent) connection to complete in order to minimize the number of OS
threads required to handle in-flight network connections. Without requiring
exposing an async callback or a mechanism to explicitly start a connection
and at a later time test whether it has been established or failed.

What might be happening for the O.P. is that the systems they are
connecting to are not explicitly accepting or rejecting the connections in
a timely manner. Thus causing a huge number of goroutines blocked waiting
for the net.Dial() to complete. The systems they are connecting to may be
simply discarding the TCP SYN packets due to firewall rules or something
similar. This is something that is going to be hard for the Go community to
provide help since it is fundamentally not an issue with Go itself.

-- 
Kurtis Rader
Caretaker of the exceptional canines Junior and Hank

-- 
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/CABx2%3DD9j-4ikWnpz9kkd1stkj9sh9rR%3DGbSCbLp3wOo%2BCsXbuA%40mail.gmail.com.

Reply via email to