So i have this code block for sending a message. The message which gets passed to c.outChan is transmitted and if an ack is recieved in return, a "true" will be passed through the c.buffer[nr].signaler channel. This seems to work fine, but if the message is dropped ( no ack recieved ), instead of reaching the timeout print, it just stoppes, and i don't know why. Here is the code:
func (c *uConnection) send(nr uint32) {
//transmitt message
c.outChan <- c.buffer[nr].msg
timeout := make(chan bool, 1)
go func() {
timeoutTimer := time.After(c.retransTime)
<-timeoutTimer
timeout <- true
}()
switch {
case <-c.buffer[nr].signaler:
fmt.Printf("Ack confirmed: %v
", nr)
case <-timeout:
fmt.Println("-----------timeout-----------
")
//resending
c.send(nr)
}
}
What am i doing wrong?