MCPcopy Create free account
hub / github.com/libp2p/go-reuseport

github.com/libp2p/go-reuseport @v0.4.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.4.0 ↗ · + Follow
16 symbols 28 edges 8 files 5 documented · 31% 21 cross-repo links ● updated 15mo agov0.4.0 · 2023-08-17★ 8073 open issues

Browse by type

⨍ Functions 16◇ Types & classes 0
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

go-reuseport

GoDoc codecov Travis CI Discourse posts

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.


The last gx published version of this module was: 0.2.2: Qme8kdM7thoCqLqd7GYCRqipoZJS64rhJo5MBcTpyWfsL9

Core symbols most depended-on inside this repo

browse all functions →

Shape

Function 16

Languages

Go100%

Modules by API surface

reuse_test.go5 symbols
interface.go5 symbols
control_windows.go1 symbols
control_wasm.go1 symbols
control_unix.go1 symbols
control_plan9.go1 symbols
control_freebsd.go1 symbols
addr.go1 symbols

For agents

$ claude mcp add go-reuseport \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page