\documentclass[]{article}
\usepackage{amsmath,graphicx,supertabular,hyperref,tabularx,ifthen}
\title{TIP \#344: Bring TCP\_NODELAY and SO\_KEEPALIVE to socket options}
\date{December 31, 2008}
\author{Alexandre Ferrieux}
\urlstyle{sf}
\setlength{\parskip}{1ex}
\setlength{\parindent}{0pt}
\def\tipversion$#1${\texttt{\$#1\$}}
\def\tiplangle#1{\ensuremath{<}}
\def\tiprangle#1{\ensuremath{>}}
\def\tipbar#1{\ensuremath{|}}
\def\tipmail#1#2{\(\langle\){\small\expandafter\url{#1@#2}}\(\rangle\)}
\ifx\pdfoutput\undefined
\newcommand{\tipimage}[2]{\typeout{Make sure you download #1.eps}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.eps}}{\includegraphics[width=0.8\textwidth]{#1.eps}}}
\newcommand{\tipxref}[1]{}
\newcommand{\tipxrefend}{}
\else
\newcommand{\tipimage}[2]{\typeout{Make sure you create #1.pdf}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.pdf}}{\includegraphics[width=0.8\textwidth]{#1.pdf}}}
\pdfcatalog{/PageMode /UseOutlines}
\newcommand{\tipxref}[1]{\pdfannotlink attr {/C [0.5 0.5 1.0] /Border [0 0 1]} goto name {#1}}
\newcommand{\tipxrefend}{\pdfendlink}
\fi
\newenvironment{tipabstract}{\begin{abstract}}{\end{abstract}}
\begin{document}\maketitle
\begin{center}\begin{tabularx}{\linewidth}{|r@{: }X|}\hline
\textbf{TIP \#344}&\textbf{Bring TCP\_NODELAY and SO\_KEEPALIVE to socket options}\\\hline
Author&

Alexandre Ferrieux \tipmail{alexandre.ferrieux}{gmail.com}
\\
Created&Wednesday, \(\text{31}^{\text{st}}\) December 2008\\
Type&Project\\
Tcl Version&\(8.7\)\\
State&Draft\\
Vote&Pending\\
Version&\tipversion$Revision: 1.2 $\\
Post History&\\
\hline\end{tabularx}\end{center}
\thispagestyle{empty}\pagestyle{empty}
\begin{tipabstract}

Just expose to script level, via \textbf{fconfigure}, the two most important setsockopt() use cases: TCP\_NODELAY (disabling the Nagle agorithm) and SO\_KEEPALIVE (sending automatic keepalives).
\end{tipabstract}
\tableofcontents\setcounter{page}{0}\clearpage\pagestyle{plain}

\section{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.

\section{Proposed Change}

This TIP proposes to add two boolean [fconfigure] options to sockets: \textbf{-nodelay} (or \textbf{-nonagle}, or \textbf{-nagle}, take your pick) and \textbf{-keepalive}.

\section{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...

\section{Copyright}

This document has been placed in the public domain.

\section{Colophon}

\textit{TIP AutoGenerator --- written by Donal K. Fellows}
\end{document}
