Documentation
¶
Overview ¶
Package reuse 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, _ := greuse.Listen("tcp", "127.0.0.1:1234") l2, _ := greuse.Listen("tcp", "127.0.0.1:1234") // dial from the same port. l1, _ := greuse.Listen("tcp", "127.0.0.1:1234") l2, _ := greuse.Listen("tcp", "127.0.0.1:1235") c, _ := greuse.Dial("tcp", "127.0.0.1:1234", "127.0.0.1:1235")
Note: can't 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 DialAddr(network string, laddr net.Addr, raddr net.Addr) (net.Conn, error)
- func DialIP(network string, laddr *net.IPAddr, raddr *net.IPAddr) (net.Conn, error)
- func DialTCP(network string, laddr *net.TCPAddr, raddr *net.TCPAddr) (net.Conn, error)
- func DialTimeOut(network, laddr, raddr string, timeout time.Duration) (net.Conn, error)
- func DialUDP(network string, laddr *net.UDPAddr, raddr *net.UDPAddr) (net.Conn, error)
- func DialUnix(network string, laddr *net.UnixAddr, raddr *net.UnixAddr) (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 returns whether or not SO_REUSEPORT or equivalent behaviour is // enabled in the OS. 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 DialAddr ¶
DialAddr 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 DialIP ¶
DialIP dials the given network and ip 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 DialTCP ¶
DialTCP dials the given network and tcp 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 DialTimeOut ¶
DialTimeOut 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 DialUDP ¶
DialUDP dials the given network and udp 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 DialUnix ¶
DialUnix dials the given network and unix 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.