ᴠɪᴄᴛᴏʀ ʙᴊᴇʟᴋʜᴏʟᴍ 3f7416390f Create Jenkinsfile
2019-01-03 15:53:07 +11:00
2019-01-03 14:58:11 +11:00
2019-01-03 15:53:07 +11:00
2018-12-28 01:07:52 +01:00
2015-01-23 16:16:15 -08:00
2019-01-03 10:31:42 +11:00
2019-01-03 10:31:42 +11:00
2019-01-02 16:14:32 +11:00
2015-01-18 20:16:39 -08:00
2018-03-23 10:21:21 -07:00
2019-01-03 11:32:21 +11:00
2019-01-03 10:12:05 +11:00
2019-01-03 15:19:37 +11:00

go-reuseport

travisbadge

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.

Description
reuse tcp/udp ports in golang
Readme ISC 364 KiB
Languages
Go 100%