Reputation: 169
I have server with several net.Conn. How can I get list of net.Conn which have unreaded messages (without using active waiting) ?
Upvotes: 1
Views: 168
Reputation: 3044
I don't think you can.
If you try to read from the net.Conn
with its Read
method, it will block until there is data. So just start a goroutine for each net.Conn
, and read from it in the goroutine.
The example in the net package's documentation does exactly that: https://pkg.go.dev/net#example-Listener
Upvotes: 4