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.
72 lines
1.1 KiB
72 lines
1.1 KiB
13 years ago
|
#ifndef SOCKET_CLIENT_HPP
|
||
|
#define SOCKET_CLIENT_HPP
|
||
13 years ago
|
|
||
13 years ago
|
|
||
13 years ago
|
#include "SocketConnection.hpp"
|
||
13 years ago
|
#include "Thread.hpp"
|
||
13 years ago
|
#include "Poll.hpp"
|
||
13 years ago
|
|
||
13 years ago
|
|
||
13 years ago
|
#include <string>
|
||
13 years ago
|
#include <stddef.h> // size_t
|
||
13 years ago
|
|
||
|
|
||
13 years ago
|
class SocketClient
|
||
13 years ago
|
{
|
||
|
private:
|
||
|
|
||
13 years ago
|
class PollerThread : public Thread
|
||
13 years ago
|
, public Poll
|
||
13 years ago
|
{
|
||
|
public:
|
||
13 years ago
|
|
||
13 years ago
|
PollerThread( SocketClient* data );
|
||
13 years ago
|
|
||
13 years ago
|
void stopPoller();
|
||
13 years ago
|
|
||
|
protected:
|
||
|
|
||
13 years ago
|
// overridig poll's behaviour
|
||
13 years ago
|
virtual void acceptClient();
|
||
13 years ago
|
|
||
13 years ago
|
// overridig poll's behaviour
|
||
13 years ago
|
virtual void handleClient( const int );
|
||
13 years ago
|
|
||
13 years ago
|
private:
|
||
|
|
||
13 years ago
|
PollerThread(const PollerThread&);
|
||
|
PollerThread& operator=(const PollerThread&);
|
||
|
|
||
13 years ago
|
void* run();
|
||
13 years ago
|
|
||
13 years ago
|
SocketClient *m_tcpClient;
|
||
13 years ago
|
|
||
|
}; // class PollerThread
|
||
13 years ago
|
|
||
13 years ago
|
|
||
|
public:
|
||
|
|
||
13 years ago
|
SocketClient (SocketConnection *connection );
|
||
13 years ago
|
|
||
13 years ago
|
virtual ~SocketClient();
|
||
13 years ago
|
|
||
13 years ago
|
bool connect();
|
||
|
void disconnect();
|
||
13 years ago
|
|
||
13 years ago
|
bool send( const void* msg, const size_t msgLen );
|
||
13 years ago
|
|
||
13 years ago
|
bool isPolling() const;
|
||
13 years ago
|
|
||
13 years ago
|
private:
|
||
|
|
||
13 years ago
|
SocketClient(const SocketClient& );
|
||
|
SocketClient& operator=(const SocketClient& );
|
||
13 years ago
|
|
||
13 years ago
|
|
||
13 years ago
|
SocketConnection *m_connection;
|
||
|
PollerThread m_watcher;
|
||
13 years ago
|
|
||
|
};
|
||
|
|
||
13 years ago
|
#endif // SOCKET_CLIENT_HPP
|