TIP 344: Bring TCP_NODELAY and SO_KEEPALIVE to socket options

Author:		Alexandre Ferrieux <[email protected]>
State:		Final
Type:		Project
Vote:		Done
Created:	31-Dec-2008
Tcl-Version:	8.7
Tcl-Branch:     tip-344
Vote-Summary:	Accepted 3/0/1
Votes-For:	JN, KW, SL
Votes-Against:	none
Votes-Present:	FV


Just expose to script level, via fconfigure, the two most important setsockopt() use cases: TCP_NODELAY (disabling the Nagle agorithm) and SO_KEEPALIVE (sending automatic keepalives).

Background & Rationale

Currently, there is no way to set nodefault values to a Tcl socket's underlying socket options TCP_NODELAY and SO_KEEPALIVE. That is frustrating because all TCP stacks support setsockopt().

Of these two options, the most important I guess is TCP_NODELAY. Indeed, the Nagle algorithm being on by default may introduce unwanted latencies in some specific cases. This TIP does not try to argument about the prevalence of these cases; the ubiquity of setsockopt(TCP_NODELAY) suffices to justify exposing it to script level.

Proposed Change

This TIP proposes to add two boolean [fconfigure] options to sockets: -nodelay and -keepalive.

Reference Implementation

Pretty trivial; will be provided shortly after validation. The code has even been in place for a long time, though only in the Windows-specific part, and commented/ifdef'ed out...


This document has been placed in the public domain.