Created
October 11, 2016 21:25
-
-
Save lucas-clemente/c12ff5549e116e750aadda952aafe7c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"net" | |
_ "net/http/pprof" | |
) | |
const host = "localhost:4242" | |
// Opens a UDP listener and ignores any data | |
func udpSink() { | |
laddr, err := net.ResolveUDPAddr("udp", host) | |
if err != nil { | |
panic(err) | |
} | |
l, err := net.ListenUDP("udp", laddr) | |
if err != nil { | |
panic(err) | |
} | |
buf := make([]byte, 1000) | |
for { | |
_, _, err := l.ReadFromUDP(buf) | |
if err != nil { | |
panic(err) | |
} | |
} | |
} | |
func main() { | |
udpSink() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment