I'm curious as to what the proper way of listening multiple simultaneous
Please consider the two implementations I currently
Receive1 is a rather simple implementation, spawning a goroutine per
connection, and simply blocking on each one via the ReadFromUDP method of
Receive2 is a more C-style approach, using the real select to block until
either one of the sockets actually receives something, and then actually
trying to read.
Now, Receive2 is _supposedly_ better, since we rely on the kernel to notify
the select if one of the file descriptors is ready for reading. That would,
under ideal conditions (and maybe less goroutines), allow the process
itself to fall asleep until data starts pouring into the socket.
Receive1 is relying on the I/O read blocking until something comes along,
and is doing so for each connection. Or at least that's what my
understanding is, I'm not sure whether internally, the connection is still
using select. Though even if it was, I don't thing the go scheduler is
smart enough to put the whole process to sleep if two separate goroutines
are waiting for I/O. That being said, Receive1 looks so much better than
If there is also a better way than either of these, please share it with me.
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 firstname.lastname@example.org.
For more options, visit https://groups.google.com/d/optout.