So, we have a full-duplex system setup that utilizes channels and different goroutines for UDP packet processing (reading, writing, handling). Thus, we block at ReadFromUDP
while waiting for incoming packets in a goroutine.
We have this peculiar problem with ReadFromUDP
throwing an error (obviously) while waiting for a packet to arrive and the connection is being closed elsewhere.
The error that is printed is the following:
read udp 127.0.0.1:8091: use of closed network connection
This is quite reasonable since we actually close the connection in another goroutine via channels.
Is there anyone who knows if there exists a way of not getting that error (other than catching it) when this occurs or if there exists another way to signal ReadFromUDP
to stop reading, without using timeouts?