ipld-eth-server/vendor/github.com/libp2p/go-reuseport
Elizabeth Engelman 36533f7c3f Update vendor directory and make necessary code changes
Fixes for new geth version
2019-09-25 16:32:27 -05:00
..
.travis.yml Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
addr.go Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
codecov.yml Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
control_unix.go Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
control_wasm.go Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
control_windows.go Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
go.mod Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
go.sum Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
interface.go Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
LICENSE Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
Makefile Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
package.json Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00
README.md Update vendor directory and make necessary code changes 2019-09-25 16:32:27 -05:00

go-reuseport

codecov Travis CI

NOTE: This package REQUIRES go >= 1.11.

This package enables listening and dialing from the same TCP or UDP port. This means that the following sockopts may be set:

SO_REUSEADDR
SO_REUSEPORT

This is a simple package to help with address reuse. This is particularly important when attempting to do TCP NAT holepunching, which requires a process to both Listen and Dial on the same TCP port. This package provides some utilities around enabling this behaviour on various OS.

Examples

// listen on the same port. oh yeah.
l1, _ := reuse.Listen("tcp", "127.0.0.1:1234")
l2, _ := reuse.Listen("tcp", "127.0.0.1:1234")
// dial from the same port. oh yeah.
l1, _ := reuse.Listen("tcp", "127.0.0.1:1234")
l2, _ := reuse.Listen("tcp", "127.0.0.1:1235")
c, _ := reuse.Dial("tcp", "127.0.0.1:1234", "127.0.0.1:1235")

Note: cant dial self because tcp/ip stacks use 4-tuples to identify connections, and doing so would clash.

Tested

Tested on darwin, linux, and windows.