40.2.3 Using transport agents via system calls
Once transport agents have been configured and applications attached,
applications can use transport
services via the following system calls. These calls can be invoked at either
OTcl or C++ level, thereby allowing applications to be coded in either C++ or
OTcl. These functions have been implemented as virtual functions in the base
class Agent, and can be redefined as needed by derived Agents.
- send(int nbytes)--Send nbytes of data to peer. For TCP agents,
if nbytes == -1, this corresponds to an ``infinite'' send; i.e., the
TCP agent will act as if its send buffer is continually replenished by the
application.
- sendmsg(int nbytes, const char* flags = 0)--Identical to
send(int nbytes), except that it passes an additional string
flags. Currently one flag value, ``MSG_EOF,'' is defined; MSG_EOF
specifies that this is the last batch of data that the application will
submit, and serves as an implied close (so that TCP can send FIN with data).
- close()--Requests the agent to close the connection (only
applicable for TCP).
- listen()--Requests the agent to listen for new connections
(only applicable for Full TCP).
- set_pkttype(int pkttype)--This function sets the type_
variable in the agent to pkttype. Packet types are defined in
packet.h. This function is used to override the transport layer
packet type for tracing purposes.
Note that certain calls are not applicable for certain agents; e.g., a call
to []close a UDP connection results in a no-op. Additional calls
can be implemented in specialized agents, provided that they are made
public member functions.
Tom Henderson
2011-11-05