SO_KEEPALIVE Slow (?) on macOS

Update: Mystery solved! Pete Kazmier reached out over e-mail asking if I could share some packet captures of the problem. I sent them to him, and he figured out the issue. The Racket implementation was passing the wrong level to setsockopt , namely IPPROTO_TCP instead of SOL_SOCKET . The particular combination of the values of IPPROTO_TCP and SO_KEEPALIVE on macOS happens to map to a configuration…