Added example answer
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*.sum
|
||||
goudpserver
|
||||
6
main.go
6
main.go
@@ -17,6 +17,12 @@ func lstn(connection *net.UDPConn, alarm chan struct{}) {
|
||||
for err == nil {
|
||||
n, remoteAddr, err = connection.ReadFromUDP(buffer)
|
||||
fmt.Println("from", remoteAddr, "-", buffer[:n])
|
||||
n, err = connection.WriteToUDP([]byte("OK"), remoteAddr)
|
||||
if err != nil {
|
||||
fmt.Println("WriteUDP Error (", err.Error(), ")")
|
||||
} else {
|
||||
fmt.Println("WriteUDP... OK")
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("Listener failed (", err, ")!")
|
||||
|
||||
Reference in New Issue
Block a user