69 virtual void close() = 0;
124 virtual size_t doSendMessage(
const std::string &message) = 0;
203 #endif // #ifndef CONNECTION_H
std::string tryReceiveMessage()
Tries to receive a message from a client.
virtual ~Connection()
Destructor.
time_t _timeout
Connection timeout.
Definition: connection.h:200
virtual void close()=0
Closes an established TCP connection.
Connection & operator=(const Connection &)
virtual std::string doReceiveMessage(Config::LengthFieldMessageLength messageLength)=0
Receives a message.
std::string receiveFixedLengthMessage(Config::LengthFieldMessageLength messageLength)
Receives a message of the selected length.
Config class - declarations.
size_t trySendMessageViaLengthField(const std::string &message)
Tries to send a message via length field.
BaseException class - declarations.
Base class for all configuration classes.
Definition: config.h:28
Base exception class for all project exceptions.
Definition: base_exception.h:23
Connection(const Config &config, time_t timeout)
Constructor.
This exception is thrown when trying to read or send a message while the connection is closed...
Definition: connection.h:43
std::string tryReceiveMessageViaBuffer()
Tries to receive a message via fixed-length buffer.
std::string tryReceiveMessageViaLengthField()
Tries to receive a message via length field.
ConnectionError(const std::string &errorMessage)
Definition: connection.h:35
size_t trySendMessage(const std::string &message)
Tries to send a message to the client.
This exception is thrown in case of a connection related problem.
Definition: connection.h:33
void sendMessageAtOnce(const std::string &message)
Sends the selected message at once.
const Config _config
Configuration.
Definition: connection.h:198
ConnectionClosed(const std::string &errorMessage)
Definition: connection.h:45
std::tr1::uint32_t LengthFieldMessageLength
Message length type when using length field.
Definition: config.h:49
virtual size_t doSendMessage(const std::string &message)=0
Sends the selected message.
Abstract class for all connection types.
Definition: connection.h:28