|
||
The example is a client for the simple Echo protocol. A server implementing this protocol, defined in RFC862, simply listens on port 7 for incoming data, and returns it to the client. The protocol is defined for both TCP and UDP. Here, we choose to use TCP.
The basic operation of the client is therefore:
connects to a server on port 7
sends characters typed to the server
reads the returned characters and prints them to the screen
The simplest option is to connect using an IP address. To illustrate using DNS, these further options are also given:
connect using a hostname, calling DNS first to resolve this to an IP address
connect using an IP address, obtaining the symbolic name for this IP address first
The echo example is located in the folder
examples\Networking\TcpIp\
. Following the usual recommendations,
the user interface and engine are implemented as separate components.
The two projects are:
echoeng
: a DLL that implements the engine
component. It contains active object classes that encapsulate reading, writing,
and connect operations.
eikecho
: a GUI application. It provides an
interface for a user to drive the engine.
echoeng
is designed to be independent of any
particular user interface. To allow this, it defines a mixin class,
MUINotify
, through which engine classes can pass up data to be
printed and error notifications. The user interface project,
eikecho
, provides a concrete implementations of this mixin.