classPiiNetworkProtocol
#include <PiiNetworkProtocol.h>
An interface for all network communication protocols.
Inherited by PiiHttpProtocol
Description
If the protocol is stateless (such as HTTP), all functions must be thread-safe. Stateful protocols do not need to provide thread safety in the communicate() function as PiiNetworkServer clones the class for each worker thread.
Constructors and destructor
|
virtual
|
Public member functions
|
virtual PiiNetworkProtocol *
|
( )
Creates a copy of the protocol. |
|
virtual void
|
The implementation of a network protocol. |
Protected member functions
Function details
-
PiiNetworkProtocol
()[protected] -
virtual ~PiiNetworkProtocol
()[virtual] -
Creates a copy of the protocol.
This function is used by PiiNetworkServer to create a copy of a protocol object for each connecting client. If the protocol implementation is re-entrant (i.e. the communicate() function can be called concurrently from many threads and there is no state associated with a client), this function can return
this. This function needs to be thread-safe.Returns
an intialized copy of the protocol object. The default implementation returns
this. -
The implementation of a network protocol.
This function should handle all the communication with a client. It is called by a network server implementation when the I/O channel with a client has been opened, but no data has been either received or sent.
Once this function returns, either by finishing the connection or by an interrupt signal, the protocol object must reset to its initial state. The same protocol object may be used to serve many successive clients.
Parameters
- dev
-
the I/O device used for two-way communication.
- controller
-
a progress controller that either allows or disallows the communication to proceed. The implementation must call the canContinue() function from time to time to check if it is still allowed to run.
Add a note
Not a single note added yet. Be the first, add yours.