New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net: DialTCP doesn't set TCP keepalive (unlike Dialer.Dial) #49345
Comments
net.DialTCP()
So it seems reasonable that |
There is a key difference, though: If #49097 is adopted then we can set keep alive for the new |
Wouldn't the way to control the keep alive setting be to use |
That works, but then you aren't using |
I guess I'm thinking that Maybe I'm missing something. |
As I see it the main reason to use |
You can change it afterwards by calling
One could also argue there's never been a way to override the default of setting |
Ah, sorry, missed the |
CL 107196 introduced a default TCP keepalive interval for Dialer and TCPListener (used by both ListenConfig and ListenTCP). Leaving DialTCP out was likely an oversight. DialTCP's documentation says it "acts like Dial". Therefore it's natural to also expect DialTCP to enable TCP keepalive by default. This commit addresses this disparity by moving the enablement logic down to the newTCPConn function, which is used by both dialer and listener. Fixes golang#49345
Change https://go.dev/cl/447917 mentions this issue: |
CL 107196 introduced a default TCP keepalive interval for Dialer and TCPListener (used by both ListenConfig and ListenTCP). Leaving DialTCP out was likely an oversight. DialTCP's documentation says it "acts like Dial". Therefore it's natural to also expect DialTCP to enable TCP keepalive by default. This commit addresses this disparity by moving the enablement logic down to the newTCPConn function, which is used by both dialer and listener. Fixes golang#49345
CL 107196 introduced a default TCP keepalive interval for Dialer and TCPListener (used by both ListenConfig and ListenTCP). Leaving DialTCP out was likely an oversight. DialTCP's documentation says it "acts like Dial". Therefore it's natural to also expect DialTCP to enable TCP keepalive by default. This commit addresses this disparity by moving the enablement logic down to the newTCPConn function, which is used by both dialer and listener. Fixes golang#49345
What version of Go are you using (
go version
)?All current versions apply.
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?Not platform specific.
What did you do?
Call
net.DialTCP()
.What did you expect to see?
The default 15s TCP keepalive setting is applied to the connection.
What did you see instead?
TCP keepalive is not enabled.
Merging this section into newTCPConn should solve this disparity between
net.Dialer.Dial[Context]()
andnet.DialTCP()
.The text was updated successfully, but these errors were encountered: