Documentation ¶
Overview ¶
Package greuseport provides Listen and Dial functions that set socket options in order to be able to reuse ports. You should only use this package if you know what SO_REUSEADDR and SO_REUSEPORT are.
For example:
// listen on the same port. l1, _ := reuse.Listen("tcp", "127.0.0.1:1234") l2, _ := reuse.Listen("tcp", "127.0.0.1:1234") // dial from the same port. 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.
Index ¶
- Variables
- func Control(network, address string, c syscall.RawConn) (err error)
- func Dial(network, laddr, raddr string) (net.Conn, error)
- func Listen(network, address string) (net.Listener, error)
- func ListenPacket(network, address string) (net.PacketConn, error)
- func ResolveAddr(network, address string) (net.Addr, error)
Constants ¶
This section is empty.
Variables ¶
var (
Enabled = false
)
Functions ¶
func Dial ¶
Dial dials the given network and address. see net.Dialer.Dial Returns a net.Conn created from a file discriptor for a socket with SO_REUSEPORT and SO_REUSEADDR option set.
func Listen ¶
Listen listens at the given network and address. see net.Listen Returns a net.Listener created from a file discriptor for a socket with SO_REUSEPORT and SO_REUSEADDR option set.
func ListenPacket ¶
func ListenPacket(network, address string) (net.PacketConn, error)
ListenPacket listens at the given network and address. see net.ListenPacket Returns a net.Listener created from a file discriptor for a socket with SO_REUSEPORT and SO_REUSEADDR option set.
Types ¶
This section is empty.