Skip to content

Instantly share code, notes, and snippets.

@madflojo
Last active May 27, 2022 14:51
Show Gist options
  • Save madflojo/865411055db6f4f6ce432e9892c4d567 to your computer and use it in GitHub Desktop.
Save madflojo/865411055db6f4f6ce432e9892c4d567 to your computer and use it in GitHub Desktop.
TCPClient - Keepalives
// Open TCP Connection
c, err := net.DialTCP("tcp", nil, addr)
if err != nil {
fmt.Printf("Unable to dial to server - %s", err)
}
// Enable Keepalives
err = c.SetKeepAlive(true)
if err != nil {
fmt.Printf("Unable to set keepalive - %s", err)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment