00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef _socketstream_h
00018 #define _socketstream_h
00019
00020 #include <spl/io/Stream.h>
00021 #include <spl/net/TcpSocket.h>
00022
00029 class SocketStream;
00030 typedef RefCountPtrCast<SocketStream, spl::IStream, spl::IStreamPtr> SocketStreamPtr;
00031 typedef WeakReference<SocketStream, spl::IStreamPtr> SocketStreamRef;
00032
00033 REGISTER_TYPEOF(120, SocketStreamPtr);
00034 REGISTER_TYPEOF( 463, SocketStreamRef );
00035
00039 class SocketStream : public spl::IStream
00040 {
00041 private:
00042
00043 inline SocketStream(const SocketStream& strm) {}
00044
00045 protected:
00046 SocketPtr m_sock;
00047
00048 SocketStream(SocketPtr sock);
00049 friend class Socket;
00050 friend class TcpSocket;
00051
00052 public:
00053 virtual ~SocketStream();
00054
00055 virtual void Close();
00056 virtual void Flush();
00057 virtual int Read(Array<byte>& buffer, const int offset, int count);
00058 virtual int ReadByte();
00059 virtual long Seek(const long offset, const SeekOrigin origin);
00060 virtual void Write(const Array<byte>& buffer, const int offset, const int count);
00061 virtual void WriteByte(byte value);
00062
00063 virtual bool CanRead() const;
00064 virtual bool CanSeek() const;
00065 virtual bool CanWrite() const;
00066
00067 virtual long Length() const;
00068 virtual long Position() const;
00069 #ifdef DEBUG
00070 virtual void ValidateMem() const;
00071 virtual void CheckMem() const;
00072 #endif
00073 };
00074
00075 REGISTER_TYPEOF(122, SocketStream);
00076
00079 #endif