Skip to content

Instantly share code, notes, and snippets.

@lucas-clemente
Created October 11, 2016 21:25
Show Gist options
  • Save lucas-clemente/c12ff5549e116e750aadda952aafe7c1 to your computer and use it in GitHub Desktop.
Save lucas-clemente/c12ff5549e116e750aadda952aafe7c1 to your computer and use it in GitHub Desktop.
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