@@ -14,9 +14,16 @@ import (
14
14
)
15
15
16
16
const (
17
- // defaultTCPKeepAlive is a default constant value for TCPKeepAlive times
18
- // See go.dev/issue/31510
19
- defaultTCPKeepAlive = 15 * time .Second
17
+ // defaultTCPKeepAliveIdle is a default constant value for TCP_KEEPIDLE.
18
+ // See go.dev/issue/31510 for details.
19
+ defaultTCPKeepAliveIdle = 15 * time .Second
20
+
21
+ // defaultTCPKeepAliveInterval is a default constant value for TCP_KEEPINTVL.
22
+ // It is the same as defaultTCPKeepAliveIdle, see go.dev/issue/31510 for details.
23
+ defaultTCPKeepAliveInterval = 15 * time .Second
24
+
25
+ // defaultTCPKeepAliveCount is a default constant value for TCP_KEEPCNT.
26
+ defaultTCPKeepAliveCount = 9
20
27
21
28
// For the moment, MultiPath TCP is not used by default
22
29
// See go.dev/issue/56539
@@ -116,13 +123,25 @@ type Dialer struct {
116
123
117
124
// KeepAlive specifies the interval between keep-alive
118
125
// probes for an active network connection.
126
+ //
127
+ // KeepAlive is ignored if KeepAliveConfig.Enable is true.
128
+ //
119
129
// If zero, keep-alive probes are sent with a default value
120
130
// (currently 15 seconds), if supported by the protocol and operating
121
131
// system. Network protocols or operating systems that do
122
- // not support keep-alives ignore this field.
132
+ // not support keep-alive ignore this field.
123
133
// If negative, keep-alive probes are disabled.
124
134
KeepAlive time.Duration
125
135
136
+ // KeepAliveConfig specifies the keep-alive probe configuration
137
+ // for an active network connection, when supported by the
138
+ // protocol and operating system.
139
+ //
140
+ // If KeepAliveConfig.Enable is true, keep-alive probes are enabled.
141
+ // If KeepAliveConfig.Enable is false and KeepAlive is negative,
142
+ // keep-alive probes are disabled.
143
+ KeepAliveConfig KeepAliveConfig
144
+
126
145
// Resolver optionally specifies an alternate resolver to use.
127
146
Resolver * Resolver
128
147
@@ -680,12 +699,24 @@ type ListenConfig struct {
680
699
681
700
// KeepAlive specifies the keep-alive period for network
682
701
// connections accepted by this listener.
683
- // If zero, keep-alives are enabled if supported by the protocol
702
+ //
703
+ // KeepAlive is ignored if KeepAliveConfig.Enable is true.
704
+ //
705
+ // If zero, keep-alive are enabled if supported by the protocol
684
706
// and operating system. Network protocols or operating systems
685
- // that do not support keep-alives ignore this field.
686
- // If negative, keep-alives are disabled.
707
+ // that do not support keep-alive ignore this field.
708
+ // If negative, keep-alive are disabled.
687
709
KeepAlive time.Duration
688
710
711
+ // KeepAliveConfig specifies the keep-alive probe configuration
712
+ // for an active network connection, when supported by the
713
+ // protocol and operating system.
714
+ //
715
+ // If KeepAliveConfig.Enable is true, keep-alive probes are enabled.
716
+ // If KeepAliveConfig.Enable is false and KeepAlive is negative,
717
+ // keep-alive probes are disabled.
718
+ KeepAliveConfig KeepAliveConfig
719
+
689
720
// If mptcpStatus is set to a value allowing Multipath TCP (MPTCP) to be
690
721
// used, any call to Listen with "tcp(4|6)" as network will use MPTCP if
691
722
// supported by the operating system.
0 commit comments