Created a struct for the UDP connection instead of juggling multiple loose vars

This commit is contained in:
2025-10-02 10:12:08 +01:00
parent e8d10e1a3c
commit 6930a7f218
2 changed files with 16 additions and 7 deletions
+3 -3
View File
@@ -20,7 +20,7 @@ func Replay(address string, port int, fp string) error {
log.Fatal("error opening file:", err)
}
addr, conn, err := openUDPServer(address, port)
udp, err := newUDPServer(address, port)
if err != nil {
return err
}
@@ -42,7 +42,7 @@ func Replay(address string, port int, fp string) error {
break
}
if _, err := conn.WriteToUDP(buf.Bytes(), addr); err != nil {
if _, err := udp.Conn.WriteToUDP(buf.Bytes(), udp.Addr); err != nil {
log.Fatal("send failed:", err)
break
}
@@ -50,5 +50,5 @@ func Replay(address string, port int, fp string) error {
<-ticker.C
}
return conn.Close()
return udp.Close()
}