anacrolix / utp

Use anacrolix/go-libutp instead
https://github.com/anacrolix/go-libutp
Mozilla Public License 2.0
173 stars 35 forks source link

Add CloseNow() to utp.Socket #16

Closed prettymuchbryce closed 7 years ago

prettymuchbryce commented 7 years ago

@anacrolix

This change adds the method CloseNow() to utp.Socket. This method attempts to block until Go has completely destroyed the underlying socket. Go has a mutex around the file descriptor under the hood so we must wait until the PacketConn has returned from all reads and writes.

This method should help to avoid "bind: address already in use" errors that can occur from lazily destroying the socket with Close() followed by recreating it on the same address as mentioned in #15.

anacrolix commented 7 years ago

Nailed it!

anacrolix commented 7 years ago

Wrong button. Merged, thanks.