Documentation
¶
Index ¶
- Constants
- Variables
- func Dial(addr string) (net.Conn, error)
- func DialDualStack(addr string) (net.Conn, error)
- func DialDualStackTimeout(addr string, timeout time.Duration) (net.Conn, error)
- func DialTimeout(addr string, timeout time.Duration) (net.Conn, error)
- type Resolver
- type TCPDialer
- func (d *TCPDialer) Dial(addr string) (net.Conn, error)
- func (d *TCPDialer) DialDualStack(addr string) (net.Conn, error)
- func (d *TCPDialer) DialDualStackTimeout(addr string, timeout time.Duration) (net.Conn, error)
- func (d *TCPDialer) DialTimeout(addr string, timeout time.Duration) (net.Conn, error)
Constants ¶
const DefaultDNSCacheDuration = time.Minute
DefaultDNSCacheDuration is the duration for caching resolved TCP addresses by Dial* functions.
const (
DefaultDialTimeout = 3 * time.Second
)
Variables ¶
var ErrDialTimeout = errors.New("dialing to the given TCP address timed out")
ErrDialTimeout is returned when TCP dialing is timed out.
Functions ¶
func Dial ¶
Dial dials the given TCP addr using tcp4.
This function has the following additional features comparing to net.Dial:
- It reduces load on DNS resolver by caching resolved TCP addressed for DefaultDNSCacheDuration.
- It dials all the resolved TCP addresses in round-robin manner until connection is established. This may be useful if certain addresses are temporarily unreachable.
- It returns ErrDialTimeout if connection cannot be established during DefaultDialTimeout seconds. Use DialTimeout for customizing dial timeout.
This dialer is intended for custom code wrapping before passing to Client.Dial or HostClient.Dial.
For instance, per-host counters and/or limits may be implemented by such wrappers.
The addr passed to the function must contain port. Example addr values:
- foobar.baz:443
- foo.bar:80
- aaa.com:8080
func DialDualStack ¶
DialDualStack dials the given TCP addr using both tcp4 and tcp6.
This function has the following additional features comparing to net.Dial:
- It reduces load on DNS resolver by caching resolved TCP addressed for DefaultDNSCacheDuration.
- It dials all the resolved TCP addresses in round-robin manner until connection is established. This may be useful if certain addresses are temporarily unreachable.
- It returns ErrDialTimeout if connection cannot be established during DefaultDialTimeout seconds. Use DialDualStackTimeout for custom dial timeout.
This dialer is intended for custom code wrapping before passing to Client.Dial or HostClient.Dial.
For instance, per-host counters and/or limits may be implemented by such wrappers.
The addr passed to the function must contain port. Example addr values:
- foobar.baz:443
- foo.bar:80
- aaa.com:8080
func DialDualStackTimeout ¶
DialDualStackTimeout dials the given TCP addr using both tcp4 and tcp6 using the given timeout.
This function has the following additional features comparing to net.Dial:
- It reduces load on DNS resolver by caching resolved TCP addressed for DefaultDNSCacheDuration.
- It dials all the resolved TCP addresses in round-robin manner until connection is established. This may be useful if certain addresses are temporarily unreachable.
This dialer is intended for custom code wrapping before passing to Client.Dial or HostClient.Dial.
For instance, per-host counters and/or limits may be implemented by such wrappers.
The addr passed to the function must contain port. Example addr values:
- foobar.baz:443
- foo.bar:80
- aaa.com:8080
func DialTimeout ¶
DialTimeout dials the given TCP addr using tcp4 using the given timeout.
This function has the following additional features comparing to net.Dial:
- It reduces load on DNS resolver by caching resolved TCP addressed for DefaultDNSCacheDuration.
- It dials all the resolved TCP addresses in round-robin manner until connection is established. This may be useful if certain addresses are temporarily unreachable.
This dialer is intended for custom code wrapping before passing to Client.Dial or HostClient.Dial.
For instance, per-host counters and/or limits may be implemented by such wrappers.
The addr passed to the function must contain port. Example addr values:
- foobar.baz:443
- foo.bar:80
- aaa.com:8080
Types ¶
type TCPDialer ¶
type TCPDialer struct { // Concurrency controls the maximum number of concurrent Dails // that can be performed using this object. // Setting this to 0 means unlimited. // // WARNING: This can only be changed before the first Dial. // Changes made after the first Dial will not affect anything. Concurrency int // This may be used to override DNS resolving policy, like this: // var dialer = &http.TCPDialer{ // Resolver: &net.Resolver{ // PreferGo: true, // StrictErrors: false, // Dial: func (ctx context.Context, network, address string) (net.Conn, error) { // d := net.Dialer{} // return d.DialContext(ctx, "udp", "8.8.8.8:53") // }, // }, // } Resolver Resolver // contains filtered or unexported fields }
TCPDialer contains options to control a group of Dial calls.
func (*TCPDialer) Dial ¶
Dial dials the given TCP addr using tcp4.
This function has the following additional features comparing to net.Dial:
- It reduces load on DNS resolver by caching resolved TCP addressed for DefaultDNSCacheDuration.
- It dials all the resolved TCP addresses in round-robin manner until connection is established. This may be useful if certain addresses are temporarily unreachable.
- It returns ErrDialTimeout if connection cannot be established during DefaultDialTimeout seconds. Use DialTimeout for customizing dial timeout.
This dialer is intended for custom code wrapping before passing to Client.Dial or HostClient.Dial.
For instance, per-host counters and/or limits may be implemented by such wrappers.
The addr passed to the function must contain port. Example addr values:
- foobar.baz:443
- foo.bar:80
- aaa.com:8080
func (*TCPDialer) DialDualStack ¶
DialDualStack dials the given TCP addr using both tcp4 and tcp6.
This function has the following additional features comparing to net.Dial:
- It reduces load on DNS resolver by caching resolved TCP addressed for DefaultDNSCacheDuration.
- It dials all the resolved TCP addresses in round-robin manner until connection is established. This may be useful if certain addresses are temporarily unreachable.
- It returns ErrDialTimeout if connection cannot be established during DefaultDialTimeout seconds. Use DialDualStackTimeout for custom dial timeout.
This dialer is intended for custom code wrapping before passing to Client.Dial or HostClient.Dial.
For instance, per-host counters and/or limits may be implemented by such wrappers.
The addr passed to the function must contain port. Example addr values:
- foobar.baz:443
- foo.bar:80
- aaa.com:8080
func (*TCPDialer) DialDualStackTimeout ¶
DialDualStackTimeout dials the given TCP addr using both tcp4 and tcp6 using the given timeout.
This function has the following additional features comparing to net.Dial:
- It reduces load on DNS resolver by caching resolved TCP addressed for DefaultDNSCacheDuration.
- It dials all the resolved TCP addresses in round-robin manner until connection is established. This may be useful if certain addresses are temporarily unreachable.
This dialer is intended for custom code wrapping before passing to Client.Dial or HostClient.Dial.
For instance, per-host counters and/or limits may be implemented by such wrappers.
The addr passed to the function must contain port. Example addr values:
- foobar.baz:443
- foo.bar:80
- aaa.com:8080
func (*TCPDialer) DialTimeout ¶
DialTimeout dials the given TCP addr using tcp4 using the given timeout.
This function has the following additional features comparing to net.Dial:
- It reduces load on DNS resolver by caching resolved TCP addressed for DefaultDNSCacheDuration.
- It dials all the resolved TCP addresses in round-robin manner until connection is established. This may be useful if certain addresses are temporarily unreachable.
This dialer is intended for custom code wrapping before passing to Client.Dial or HostClient.Dial.
For instance, per-host counters and/or limits may be implemented by such wrappers.
The addr passed to the function must contain port. Example addr values:
- foobar.baz:443
- foo.bar:80
- aaa.com:8080