Created
July 17, 2016 15:38
-
-
Save prettymuchbryce/ee7a74fe1905dd29190e8f91dc822e88 to your computer and use it in GitHub Desktop.
Close() on *net.UDPConn is not calling close syscall
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" | |
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