I am trying to write a simple program that communicates over UDP using GO. It's supposed to have a master/slave architecture, and therefore I want the master to send an "alive"-signal ten times a second. Since I also want the master to listen for messages from the slaves, I start a goroutine with the receive function. In testing I only use one computer, so that the only thing it receives is it's own alive-signal. Yet, after receiveng about 20 messages the program freezes. I've tried running the program only sending messages, and it doesn't freeze. Here is the receive function:
func receive(conn *net.UDPConn){
//Receive message from network
received := make([]byte,1024)
for ; true ; {
_, _, _ = conn.ReadFromUDP(received)
println("Motatt: ", string(received))
go receiveMessage(string(received))
}
}
The function receiveMessage() is simply a function that reads the message it has received.
What I am wondering is if there is a setting or something in GO that causes the freeze? As far as I understand it cannot be a deadline error since there are messages to receive.