After applications are instantiated, they must be connected to a transport agent. The attach-agent method can be used to attach an application to an agent, as follows:
set ftp1 [new Application/FTP] $ftp1 attach-agent $src
The following shortcut accomplishes the same result:
set ftp1 [$src attach-app FTP]
The attach-agent method, which is also used by attach-app, is implemented in C++. It sets the agent_ pointer in class Application to point to the transport agent, and then it calls attachApp() in agent.cc to set the app_ pointer to point back to the application. By maintaining this binding only in C++, OTcl-level instvars pointers are avoided and consistency between OTcl and C++ is guaranteed. The OTcl-level command [$ftp1 agent] can be used by applications to obtain the handler for the transport agent.