00001 00008 #ifndef SOCKET_H 00009 #define SOCKET_H 00010 00016 class BlockingException : public exception { 00017 public: 00018 BlockingException(int errcode = 0) : mErrCode(errcode) {}; 00019 int mErrCode; 00020 }; 00021 00026 class ShutdownException : public exception { 00027 public: 00028 ShutdownException(int errcode = 0) : mErrCode(errcode) {}; 00029 int mErrCode; 00030 }; 00031 00037 class IOErrorException : public exception { 00038 public: 00039 IOErrorException(int errcode = 0) : mErrCode(errcode) {}; 00040 int mErrCode; 00041 }; 00042 00053 class Socket { 00054 public: 00055 Socket(SOCKET mSock, int size = 4096); 00056 Socket(const Socket& r_sock); 00057 virtual ~Socket(); 00058 char Read(); 00059 void Write(const char c); 00060 void Write(const string& r_str); 00061 void Write(const char* p_char); 00062 void Write(const char* p_char, int len); 00063 void Flush(); 00064 SOCKET GetSocket(); 00065 void Close(); 00066 private: 00067 Socket& operator= (const Socket& r_sock); 00068 00069 SOCKET mSock; 00070 int mSize; 00071 char * mpInBuffer; 00072 char * mpOutBuffer; 00073 char * mpRead; 00074 char * mpEod; 00075 char * mpWrite; 00076 char * mpStartWrite; 00077 }; 00078 00079 #endif // SOCKET_H
1.2.17