00001 /* 00002 * $Id: OldTCPSocket.h 566 2007-12-02 08:20:52Z mindstorm2600 $ 00003 */ 00004 #ifndef __XVR2_OLD_TCP_SOCKET_H__ 00005 #define __XVR2_OLD_TCP_SOCKET_H__ 00006 #include<sys/socket.h> 00007 00008 #include<xvr2/String.h> 00009 #include<xvr2/Net/OldSocket.h> 00010 #include<xvr2/Net/IPv4Address.h> 00011 #include<xvr2/Net/NetworkExceptions.h> 00012 #include<xvr2/InvalidParameterException.h> 00013 #include<xvr2/RawInputStream.h> 00014 #include<xvr2/RawOutputStream.h> 00015 00016 namespace xvr2{ 00017 namespace Net { 00018 00029 class OldTCPSocket:public OldSocket{ 00030 protected: 00031 bool _created; 00034 char *host; 00043 int CreateSocket(const IPv4Address *addr, int theport); 00044 int CreateSocket(const char *thehost, int theport); 00045 RawInputStream out; 00046 RawOutputStream in; 00047 public: 00050 OldTCPSocket(); 00058 //OldTCPSocket(const char *thehost, int theport); 00059 OldTCPSocket(const String &thehost, int theport); 00067 OldTCPSocket(int s, int pport); 00069 OldTCPSocket(OldTCPSocket *s); 00073 OldTCPSocket(const OldTCPSocket &s); 00074 OldTCPSocket(const IPv4Address *ip, int theport); 00075 OldTCPSocket(const IPv4Address &ip, int theport); 00079 OldTCPSocket &operator=(const OldTCPSocket &s); 00083 virtual ~OldTCPSocket(); 00088 void close(void); 00092 const int getPort(){ 00093 return port; 00094 } 00095 00100 void writeLine(const char *str); 00105 void writeLine(const String &str); 00114 virtual void write(const void *buffer, unsigned long size); 00115 //const OldTCPSocket &operator << (const String &str) const; 00127 virtual void readLine(char **str); 00137 virtual int read(void *buffer, unsigned long size); 00138 virtual std::string toString(); 00139 00140 RawInputStream &outputStream(); 00141 RawOutputStream &inputStream(); 00142 00143 }; 00144 }; //End of Network namespace directive 00145 }; //End of xvr2 namespace directive 00146 00147 #endif