152a38012Sejakowatz // Sun, 18 Jun 2000 252a38012Sejakowatz // Y.Takagi 352a38012Sejakowatz 4926f1247SMichael Pfeiffer #ifndef __SocketStream_H 5926f1247SMichael Pfeiffer #define __SocketStream_H 6926f1247SMichael Pfeiffer 7*6b376d60SOliver Tappe #include <iostream> 8926f1247SMichael Pfeiffer 9926f1247SMichael Pfeiffer class Socket; 10926f1247SMichael Pfeiffer 11926f1247SMichael Pfeiffer class socketstreambuf : public streambuf { 12926f1247SMichael Pfeiffer public: 13926f1247SMichael Pfeiffer explicit socketstreambuf(Socket *sock, streamsize n); 14926f1247SMichael Pfeiffer ~socketstreambuf(); 15926f1247SMichael Pfeiffer 16926f1247SMichael Pfeiffer protected: 17926f1247SMichael Pfeiffer virtual int underflow(); 18926f1247SMichael Pfeiffer virtual int overflow(int); 19926f1247SMichael Pfeiffer virtual int sync(); 20926f1247SMichael Pfeiffer 21926f1247SMichael Pfeiffer private: 22926f1247SMichael Pfeiffer Socket *__sock; 23926f1247SMichael Pfeiffer streamsize __alsize; 24926f1247SMichael Pfeiffer char *__pu; 25926f1247SMichael Pfeiffer char *__po; 26926f1247SMichael Pfeiffer }; 27926f1247SMichael Pfeiffer 28926f1247SMichael Pfeiffer class socketstreambase : public virtual ios { 29926f1247SMichael Pfeiffer public: 30926f1247SMichael Pfeiffer socketstreambuf *rdbuf(); 31926f1247SMichael Pfeiffer 32926f1247SMichael Pfeiffer protected: 33926f1247SMichael Pfeiffer socketstreambase(Socket *sock, streamsize n); ~socketstreambase()34926f1247SMichael Pfeiffer ~socketstreambase() {} 35926f1247SMichael Pfeiffer 36926f1247SMichael Pfeiffer private: 37926f1247SMichael Pfeiffer socketstreambuf buf; 38926f1247SMichael Pfeiffer }; 39926f1247SMichael Pfeiffer rdbuf()40926f1247SMichael Pfeifferinline socketstreambuf *socketstreambase::rdbuf() 41926f1247SMichael Pfeiffer { 42926f1247SMichael Pfeiffer return &this->buf; 43926f1247SMichael Pfeiffer } 44926f1247SMichael Pfeiffer 45926f1247SMichael Pfeiffer class isocketstream : public socketstreambase, public istream { 46926f1247SMichael Pfeiffer public: 47926f1247SMichael Pfeiffer explicit isocketstream(Socket *sock, streamsize n = 4096); 48926f1247SMichael Pfeiffer virtual ~isocketstream(); 49926f1247SMichael Pfeiffer }; 50926f1247SMichael Pfeiffer 51926f1247SMichael Pfeiffer 52926f1247SMichael Pfeiffer class osocketstream : public socketstreambase, public ostream { 53926f1247SMichael Pfeiffer public: 54926f1247SMichael Pfeiffer explicit osocketstream(Socket *sock, streamsize n = 4096); 55926f1247SMichael Pfeiffer virtual ~osocketstream(); 56926f1247SMichael Pfeiffer }; 57926f1247SMichael Pfeiffer 58926f1247SMichael Pfeiffer #endif // __SocketStream_H 59