\documentclass[]{article}
\usepackage{amsmath,graphicx,supertabular,hyperref,tabularx,ifthen}
\title{TIP \#130: Unique DDE server names.}
\date{March 23, 2003}
\author{Pat Thoyts}
\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 \#130}&\textbf{Unique DDE server names.}\\\hline
Author&

Pat Thoyts \tipmail{patthoyts}{users.sourceforge.net}
\\
Created&Sunday, \(\text{23}^{\text{rd}}\) March 2003\\
Type&Project\\
Tcl Version&\(8.5\)\\
State&Final\\
Vote&Done\\
Version&\tipversion$Revision: 1.4 $\\
Post History&\\
\hline\end{tabularx}\end{center}
\thispagestyle{empty}\pagestyle{empty}
\begin{tipabstract}

The \textit{dde} package server registration code should ensure that the server names are unique. The proposed changes will mean end-user visible changes for some scripts.
\end{tipabstract}
\tableofcontents\setcounter{page}{0}\clearpage\pagestyle{plain}

\section{Rationale}

This TIP is really driven by Bug 219293 [\url{http://sf.net/tracker/?func=detail&aid=219293&group_id=10894&atid=110894}]

The DDE system actually identifies servers by combination of window ID and a service and topic string identifier. There is nothing to prevent multiple servers having the same string identifiers but it is then a problem to determine which server you need to communicate with.

The \textit{tk appname} command handles a similar situation by making the name unique during registration by appending a numerical suffix to the suggested name and then returning the name registered as the result of the command.

\section{Proposed Changes}

This TIP proposes to use the \textit{tk appname} unique name algorithm within the DDE server-name registration code. This TIP also proposes a \textit{-force} option to this command to force the suggested name to be registered. The \textit{-force} option would then provide the current registration scheme.

\section{Reference Implementation}

See the patch attached to SF patch 690354 [\url{https://sourceforge.net/tracker/?func=detail&aid=690354&group_id=10894&atid=310894}]

\section{Consequences}

Firstly the \textit{dde servername} command may register a different name than that provided to the command. Scripts will need to check the name actually registered by either maintaining the result of this command, or by executing the \textit{dde servername} command without any arguments. This may impact scripts that assume the supplied argument was in fact the name registered.

Secondly, the name registration code must obtain a list of the dde server names currently registered on the system. It can do this by effectively calling \textit{dde services TclEval}. In previous versions of the \textit{dde} package there is a potential for the \textit{dde services} command to hang in the presence of applications that are not processing messages. However, this issue has been addressed by Bug 707822's resolution.

\section{Copyright}

This document is hereby placed in the public domain.

\section{Colophon}

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