Skip to content

Instantly share code, notes, and snippets.

@prettymuchbryce
Created July 17, 2016 15:38
Show Gist options
  • Save prettymuchbryce/ee7a74fe1905dd29190e8f91dc822e88 to your computer and use it in GitHub Desktop.
Save prettymuchbryce/ee7a74fe1905dd29190e8f91dc822e88 to your computer and use it in GitHub Desktop.
Close() on *net.UDPConn is not calling close syscall
package main
import "net"
const maxRecvSize = 0x2000
func main() {
for i := 0; i < 100000; i++ {
p, err := net.ListenPacket("udp", "127.0.0.1:3000")
if err != nil {
// Eventually: listen udp 127.0.0.1:3000: bind: address already in use
panic(err)
}
go func() {
var b [maxRecvSize]byte
for {
_, _, err := p.ReadFrom(b[:])
if err != nil {
return
}
}
}()
err = p.Close()
if err != nil {
panic(err)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment