Skip to content

Instantly share code, notes, and snippets.

@lucas-clemente
Created October 11, 2016 21:25
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