Documentation ¶
Overview ¶
Package netx enables port reuse feature on the network transport and provides transparent network address reflection interface through Session Traversal Utilities for NAT (STUN).
Index ¶
- func Dial(network, address string) (net.Conn, error)
- func DialTCP(network, laddr, raddr string) (*net.TCPConn, error)
- func DialTimeout(network, address string, timeout time.Duration) (net.Conn, error)
- func DialTimeoutTCP(network, laddr, raddr string, timeout time.Duration) (*net.TCPConn, error)
- func DialTimeoutUDP(network, laddr, raddr string, timeout time.Duration) (*net.UDPConn, error)
- func DialUDP(network, laddr, raddr string) (*net.UDPConn, error)
- func IsPortReusable() bool
- func Listen(network, address string) (net.Listener, error)
- func ListenPacket(network, address string) (net.PacketConn, error)
- func ListenTCP(network, address string) (*net.TCPListener, error)
- func ListenUDP(network, address string) (*net.UDPConn, error)
- func ReusePort(network, address string, c syscall.RawConn) error
- type UDPConn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dial ¶
Dial connects to the address on the named network with reuse port enabled.
The network must be "tcp", "tcp4", "tcp6", "udp", "udp4", or "udp6".
See func net.Dial for a description of the network and address parameters.
func DialTCP ¶
DialTCP acts like Dial for TCP networks.
If laddr is empty, a local address is automatically chosen.
func DialTimeout ¶
DialTimeout acts like Dial but takes a timeout.
See func Dial and net.DialTimeout for further details.
func DialTimeoutTCP ¶
DialTimeoutTCP acts like DialTCP but takes a timeout.
func DialTimeoutUDP ¶
DialTimeoutUDP acts like DialUDP but takes a timeout.
func DialUDP ¶
DialUDP acts like Dial for UDP networks.
If laddr is empty, a local address is automatically chosen.
func IsPortReusable ¶
func IsPortReusable() bool
IsPortReusable checks whether port reuse feature is available or not.
func Listen ¶
Listen announces on the local network address with reuse port enabled.
The network must be "tcp", "tcp4", or "tcp6".
See func net.Listen for further details.
func ListenPacket ¶
func ListenPacket(network, address string) (net.PacketConn, error)
ListenPacket announces on the local network address with reuse port enabled.
The network must be "udp", "udp4", or "udp6".
See func net.Listen for further details.
func ListenTCP ¶
func ListenTCP(network, address string) (*net.TCPListener, error)
ListenTCP acts like Listen for TCP networks.
func ReusePort ¶
ReusePort used by netx to enable reuse port feature by default. It also can be used on the Control field in net.ListenConfig or net.Dialer to create custom ListenConfig or Dialer with reuse port capability.
lc := net.ListenConfig{Control: netx.ReusePort} listener, err := lc.Listen("tcp", ":3000")
ReusePort only available on TCP and UDP connection.
Types ¶
type UDPConn ¶
type UDPConn struct {
// contains filtered or unexported fields
}
UDPConn is the remote bind address reflection interface for net.UDPConn.
func ListenRemoteUDP ¶
ListenRemoteUDP acts like ListenUDP but with remote bind address reflection.
func (*UDPConn) RemoteAddr ¶
RemoteAddr returns the reflected remote bind address. The Addr returned is shared by all invocations of RemoteAddr, so do not modify it.