const defaultTCPKeepAliveIdle … const defaultTCPKeepAliveInterval … const defaultTCPKeepAliveCount … const defaultMPTCPEnabledListen … const defaultMPTCPEnabledDial … var multipathtcp … type mptcpStatusDial … const mptcpUseDefaultDial … const mptcpEnabledDial … const mptcpDisabledDial … func (m *mptcpStatusDial) get() bool { … } func (m *mptcpStatusDial) set(use bool) { … } type mptcpStatusListen … const mptcpUseDefaultListen … const mptcpEnabledListen … const mptcpDisabledListen … func (m *mptcpStatusListen) get() bool { … } func (m *mptcpStatusListen) set(use bool) { … } type Dialer … func (d *Dialer) dualStack() bool { … } func minNonzeroTime(a, b time.Time) time.Time { … } // deadline returns the earliest of: // - now+Timeout // - d.Deadline // - the context's deadline // // Or zero, if none of Timeout, Deadline, or context's deadline is set. func (d *Dialer) deadline(ctx context.Context, now time.Time) (earliest time.Time) { … } func (d *Dialer) resolver() *Resolver { … } // partialDeadline returns the deadline to use for a single address, // when multiple addresses are pending. func partialDeadline(now, deadline time.Time, addrsRemaining int) (time.Time, error) { … } func (d *Dialer) fallbackDelay() time.Duration { … } func parseNetwork(ctx context.Context, network string, needsProto bool) (afnet string, proto int, err error) { … } // resolveAddrList resolves addr using hint and returns a list of // addresses. The result contains at least one address when error is // nil. func (r *Resolver) resolveAddrList(ctx context.Context, op, network, addr string, hint Addr) (addrList, error) { … } // MultipathTCP reports whether MPTCP will be used. // // This method doesn't check if MPTCP is supported by the operating // system or not. func (d *Dialer) MultipathTCP() bool { … } // SetMultipathTCP directs the [Dial] methods to use, or not use, MPTCP, // if supported by the operating system. This method overrides the // system default and the GODEBUG=multipathtcp=... setting if any. // // If MPTCP is not available on the host or not supported by the server, // the Dial methods will fall back to TCP. func (d *Dialer) SetMultipathTCP(use bool) { … } // Dial connects to the address on the named network. // // Known networks are "tcp", "tcp4" (IPv4-only), "tcp6" (IPv6-only), // "udp", "udp4" (IPv4-only), "udp6" (IPv6-only), "ip", "ip4" // (IPv4-only), "ip6" (IPv6-only), "unix", "unixgram" and // "unixpacket". // // For TCP and UDP networks, the address has the form "host:port". // The host must be a literal IP address, or a host name that can be // resolved to IP addresses. // The port must be a literal port number or a service name. // If the host is a literal IPv6 address it must be enclosed in square // brackets, as in "[2001:db8::1]:80" or "[fe80::1%zone]:80". // The zone specifies the scope of the literal IPv6 address as defined // in RFC 4007. // The functions [JoinHostPort] and [SplitHostPort] manipulate a pair of // host and port in this form. // When using TCP, and the host resolves to multiple IP addresses, // Dial will try each IP address in order until one succeeds. // // Examples: // // Dial("tcp", "golang.org:http") // Dial("tcp", "192.0.2.1:http") // Dial("tcp", "198.51.100.1:80") // Dial("udp", "[2001:db8::1]:domain") // Dial("udp", "[fe80::1%lo0]:53") // Dial("tcp", ":80") // // For IP networks, the network must be "ip", "ip4" or "ip6" followed // by a colon and a literal protocol number or a protocol name, and // the address has the form "host". The host must be a literal IP // address or a literal IPv6 address with zone. // It depends on each operating system how the operating system // behaves with a non-well known protocol number such as "0" or "255". // // Examples: // // Dial("ip4:1", "192.0.2.1") // Dial("ip6:ipv6-icmp", "2001:db8::1") // Dial("ip6:58", "fe80::1%lo0") // // For TCP, UDP and IP networks, if the host is empty or a literal // unspecified IP address, as in ":80", "0.0.0.0:80" or "[::]:80" for // TCP and UDP, "", "0.0.0.0" or "::" for IP, the local system is // assumed. // // For Unix networks, the address must be a file system path. func Dial(network, address string) (Conn, error) { … } // DialTimeout acts like [Dial] but takes a timeout. // // The timeout includes name resolution, if required. // When using TCP, and the host in the address parameter resolves to // multiple IP addresses, the timeout is spread over each consecutive // dial, such that each is given an appropriate fraction of the time // to connect. // // See func Dial for a description of the network and address // parameters. func DialTimeout(network, address string, timeout time.Duration) (Conn, error) { … } type sysDialer … // Dial connects to the address on the named network. // // See func Dial for a description of the network and address // parameters. // // Dial uses [context.Background] internally; to specify the context, use // [Dialer.DialContext]. func (d *Dialer) Dial(network, address string) (Conn, error) { … } // DialContext connects to the address on the named network using // the provided context. // // The provided Context must be non-nil. If the context expires before // the connection is complete, an error is returned. Once successfully // connected, any expiration of the context will not affect the // connection. // // When using TCP, and the host in the address parameter resolves to multiple // network addresses, any dial timeout (from d.Timeout or ctx) is spread // over each consecutive dial, such that each is given an appropriate // fraction of the time to connect. // For example, if a host has 4 IP addresses and the timeout is 1 minute, // the connect to each single address will be given 15 seconds to complete // before trying the next one. // // See func [Dial] for a description of the network and address // parameters. func (d *Dialer) DialContext(ctx context.Context, network, address string) (Conn, error) { … } // dialParallel races two copies of dialSerial, giving the first a // head start. It returns the first established connection and // closes the others. Otherwise it returns an error from the first // primary address. func (sd *sysDialer) dialParallel(ctx context.Context, primaries, fallbacks addrList) (Conn, error) { … } // dialSerial connects to a list of addresses in sequence, returning // either the first successful connection, or the first error. func (sd *sysDialer) dialSerial(ctx context.Context, ras addrList) (Conn, error) { … } // dialSingle attempts to establish and returns a single connection to // the destination address. func (sd *sysDialer) dialSingle(ctx context.Context, ra Addr) (c Conn, err error) { … } type ListenConfig … // MultipathTCP reports whether MPTCP will be used. // // This method doesn't check if MPTCP is supported by the operating // system or not. func (lc *ListenConfig) MultipathTCP() bool { … } // SetMultipathTCP directs the [Listen] method to use, or not use, MPTCP, // if supported by the operating system. This method overrides the // system default and the GODEBUG=multipathtcp=... setting if any. // // If MPTCP is not available on the host or not supported by the client, // the Listen method will fall back to TCP. func (lc *ListenConfig) SetMultipathTCP(use bool) { … } // Listen announces on the local network address. // // See func Listen for a description of the network and address // parameters. // // The ctx argument is used while resolving the address on which to listen; // it does not affect the returned Listener. func (lc *ListenConfig) Listen(ctx context.Context, network, address string) (Listener, error) { … } // ListenPacket announces on the local network address. // // See func ListenPacket for a description of the network and address // parameters. // // The ctx argument is used while resolving the address on which to listen; // it does not affect the returned Listener. func (lc *ListenConfig) ListenPacket(ctx context.Context, network, address string) (PacketConn, error) { … } type sysListener … // Listen announces on the local network address. // // The network must be "tcp", "tcp4", "tcp6", "unix" or "unixpacket". // // For TCP networks, if the host in the address parameter is empty or // a literal unspecified IP address, Listen listens on all available // unicast and anycast IP addresses of the local system. // To only use IPv4, use network "tcp4". // The address can use a host name, but this is not recommended, // because it will create a listener for at most one of the host's IP // addresses. // If the port in the address parameter is empty or "0", as in // "127.0.0.1:" or "[::1]:0", a port number is automatically chosen. // The [Addr] method of [Listener] can be used to discover the chosen // port. // // See func [Dial] for a description of the network and address // parameters. // // Listen uses context.Background internally; to specify the context, use // [ListenConfig.Listen]. func Listen(network, address string) (Listener, error) { … } // ListenPacket announces on the local network address. // // The network must be "udp", "udp4", "udp6", "unixgram", or an IP // transport. The IP transports are "ip", "ip4", or "ip6" followed by // a colon and a literal protocol number or a protocol name, as in // "ip:1" or "ip:icmp". // // For UDP and IP networks, if the host in the address parameter is // empty or a literal unspecified IP address, ListenPacket listens on // all available IP addresses of the local system except multicast IP // addresses. // To only use IPv4, use network "udp4" or "ip4:proto". // The address can use a host name, but this is not recommended, // because it will create a listener for at most one of the host's IP // addresses. // If the port in the address parameter is empty or "0", as in // "127.0.0.1:" or "[::1]:0", a port number is automatically chosen. // The LocalAddr method of [PacketConn] can be used to discover the // chosen port. // // See func [Dial] for a description of the network and address // parameters. // // ListenPacket uses context.Background internally; to specify the context, use // [ListenConfig.ListenPacket]. func ListenPacket(network, address string) (PacketConn, error) { … }