00001 #ifndef ZESOCKET_H 00002 #define ZESOCKET_H 00003 00004 #include <abuse/abuse.h> 00005 #include <abuse/ZeBuffer.h> 00006 #include <abuse/net_error.h> 00007 00008 class Url; 00009 00010 class ZeSocket 00011 { 00012 public: 00013 ZeSocket(int type=SOCK_STREAM)throw(net_error); 00014 ZeSocket(SOCKET s,bool dummy)throw(net_error); 00015 virtual ~ZeSocket(); 00016 void connect(const Url& url,short int port)throw(net_error); 00017 void send(const std::string& s)throw(net_error); 00018 void send(const ZeBuffer<byte>& buffer)throw(net_error); 00019 void send(const byte* buf,size_t size)throw(net_error); 00020 std::string receiveString(int maxbytes=0)throw(std::runtime_error); 00021 std::string receiveLine()throw(net_error); 00022 ZeBuffer<byte> receive(int maxbytes=0)throw(std::runtime_error); 00023 ZeBuffer<byte> receiveNoWait()throw(std::runtime_error); 00024 std::string receiveStringNoWait()throw(net_error); 00025 void close()throw(net_error); 00026 bool eof()throw(net_error); 00027 const std::string& getLocalName()const; 00028 int howMuchToRead()const; 00029 protected: 00030 bool m_eof; 00031 SOCKET m_socket; 00032 int type; 00033 sockaddr_in m_sockaddr; 00034 private: 00035 ZeSocket(const ZeSocket& copy);//not impl 00036 void operator=(const ZeSocket& copy);//not impl 00037 }; 00038 00039 #endif //ZESOCKET_H