#include <Protocol.h>
It reads a line from a generalized file (disk file, socket, whatever), sends it as a service request to the actual protocol implementation, and sends the returned reply to a client.
Public Methods | |
| Protocol () | |
| Create a new Protocol with no file. | |
| Protocol (util::io::GeneralFile *f) | |
| Create a Protocol that reads and writes f. | |
| Protocol (util::io::GeneralFile &f) | |
| Create a Protocol that reads and writes f. | |
| virtual | ~Protocol () |
| void | setFile (util::io::GeneralFile *f) |
| Set the file that this protocol works with. | |
| void | setFile (util::io::GeneralFile &f) |
| Set the file that this protocol works with. | |
| util::io::GeneralFile * | getFile (void) |
| Get the file this protocol uses for communications. | |
| void | start (void) |
| Start the protocol. | |
| virtual std::string | request (const std::string &r, int n)=0 throw (ConnectionClosedException&) |
| A service request. | |
Protected Attributes | |
| util::io::GeneralFile * | _pFile |
| A pointer to the file that is used for communications. | |
|
|
Create a Protocol that reads and writes f. The memory pointed to by f is automatically released upon the deletion of this protocol.
|
|
|
Create a Protocol that reads and writes f. The memory referenced by f is not automatically released. Note that a pointer to the file is stored, so that the actual object must be available through the life cycle of this protocol.
|
|
||||||||||||
|
A service request. When started, the protocol will start delivering service request to the subclass that implements this method. After reading a line from the client, the protocol will pass it to the subclass, which should reply with requested data. When the protocol has done its due and wants to break the request-reply loop, it should throw a ConnectionClosedException&. The message stored in the thrown exception will be shown to the client if it differs from NULL.
|
|
|
Set the file that this protocol works with. Data is read and written from the specified file. Memory is not automatically released. |
|
|
Set the file that this protocol works with. Data is read and written from the specified file. Memory is automatically released. |
|
|
Start the protocol. This will start a request-reply loop that can be broken by a subclass by throwing a ConnectionClosedException from the request method. |