You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
53 lines
1.1 KiB
53 lines
1.1 KiB
#ifndef TCP_CONNECTION_HPP
|
|
#define TCP_CONNECTION_HPP
|
|
|
|
|
|
#include "StreamConnection.hpp"
|
|
#include "Message.hpp"
|
|
#include "Socket.hpp"
|
|
|
|
#include <string>
|
|
|
|
|
|
class TcpConnection : public StreamConnection
|
|
{
|
|
public:
|
|
|
|
TcpConnection ( const int socket,
|
|
Message *message,
|
|
const size_t bufferLength = 1024 );
|
|
|
|
TcpConnection ( const std::string host,
|
|
const int port,
|
|
Message *message,
|
|
const size_t bufferLength = 1024 );
|
|
|
|
virtual ~TcpConnection();
|
|
|
|
Connection* clone(const int socket);
|
|
|
|
bool connect();
|
|
bool disconnect();
|
|
|
|
bool send( const void* message, const size_t length );
|
|
bool receive();
|
|
|
|
int getSocket() const;
|
|
|
|
bool bind();
|
|
bool listen( const int maxPendingQueueLen = 64 );
|
|
|
|
private:
|
|
|
|
TcpConnection(const TcpConnection&);
|
|
TcpConnection& operator=(const TcpConnection&);
|
|
|
|
Socket m_socket;
|
|
Message *m_message;
|
|
unsigned char *m_buffer;
|
|
size_t m_bufferLength;
|
|
};
|
|
|
|
|
|
#endif // TCP_CONNECTION_HPP
|