00001 00025 #ifndef __MAGIC_SOCKET_H__ 00026 #define __MAGIC_SOCKET_H__ 00027 00028 #include <magic/miodevice.h> 00029 00030 00033 class Socket : public IODevice { 00034 public: 00035 Socket (int mode=0); 00036 virtual ~Socket (); 00037 00038 int socket () const {return mSocket;} 00039 void setSocket (int socket); 00040 00041 String peerName () const; 00042 uint port () const; 00043 uint peerPort () const; 00044 uint address () const; 00045 uint peerAddress () const; 00046 00047 virtual bool open (int mode); 00048 virtual uint size () const {return 0;} 00049 virtual int at () const {return 0;} 00050 bool reset (); 00051 virtual int readBlock (char* data, uint maxlen); 00052 virtual int writeBlock (const char* data, uint len); 00053 virtual int readLine (char* data, uint maxlen); 00054 int writeBlock (const String&); 00055 virtual char getch (); 00056 virtual void putch (char ch); 00057 virtual void ungetch (char ch); 00058 00059 protected: 00060 int mSocket; 00061 }; 00062 00063 00064 class ClientSocket : public Socket { 00065 public: 00066 virtual void connect (const String& host, uint port); 00067 }; 00068