Assuming we are listening on a TCP port (using listener, err := net.Listen("tcp", ":8081")
for example), is it OK to call listener.Accept()
in different goroutines concurrently? Does it help with maximizing accepting speed?
net.Listener is a FileDescriptor under the hood. Accept() use Plan9 machinery which guards it with readLock while function and produce connection - newFD. So it looks safe. And because of Lock is read only, no exclusive, you even can get some speedup calling accept concurrently to my mind.