I want to turn on TCP keepalives on an HTTP session.
I'm running ruby 2.6.3 on Linux, and http-3.3.0 gem is installed.
I can set the socket options on a socket object like this:
s = TCPSocket.new('127.0.0.1', 80)
s.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)
s.setsockopt(Socket::SOL_TCP, Socket::TCP_KEEPIDLE, 5)
s.setsockopt(Socket::SOL_TCP, Socket::TCP_KEEPINTVL, 20)
s.setsockopt(Socket::SOL_TCP, Socket::TCP_KEEPCNT, 5)
However, I am using a library that uses HTTP like this:
client = HTTP::Client.new(follow: follow_option)
And I get back the client object. So, I'd like to be able to set the socket option using the client variable. I figure I need to get the underlying socket object from client, but I do not know how.
I am new to ruby, but I have 20+ years in a bunch of other languages (python, perl, and c mostly), so pardon the stupid question, if it's easy.