44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
#ifndef _CHAT_GENERICSERVER_HPP_
|
|
#define _CHAT_GENERICSERVER_HPP_
|
|
#ifndef _SOCKET_HOSTENT_HPP_
|
|
#include <socket/hostent.hpp>
|
|
#endif
|
|
#ifndef _SOCKET_SERVENT_HPP_
|
|
#include <socket/servent.hpp>
|
|
#endif
|
|
#ifndef _SOCKET_INETSOCKETADDRESS_HPP_
|
|
#include <socket/intsaddr.hpp>
|
|
#endif
|
|
#ifndef _SOCKET_SOCKET_HPP_
|
|
#include <socket/socket.hpp>
|
|
#endif
|
|
|
|
class String;
|
|
|
|
class GenericServer
|
|
{
|
|
public:
|
|
GenericServer(void);
|
|
virtual ~GenericServer();
|
|
WORD listen(const String &hostName,short portNum);
|
|
WORD send(const char &charData);
|
|
WORD send(const String &sendString);
|
|
WORD receive(String &receiveString,BOOL waitForData=TRUE);
|
|
WORD receive(Block<String> &receiveStrings);
|
|
WORD receive(char &charData,BOOL waitForData=TRUE);
|
|
void close(void);
|
|
protected:
|
|
virtual void acceptHandler(void);
|
|
virtual BOOL stringHandler(const String &stringData);
|
|
virtual void message(const String &message);
|
|
virtual void message(Block<String> &msgData);
|
|
private:
|
|
enum{TimeOut=1000};
|
|
INETSocketAddress mInternetSocketAddress;
|
|
Socket mGenericControl;
|
|
Socket mPortControl;
|
|
WSASystem mWSASystem;
|
|
BOOL mIsRunning;
|
|
};
|
|
|
|
#endif |