00001 00002 #ifndef header_buffered_socket 00003 #define header_buffered_socket 00004 00006 00007 #include "socket.h" 00008 00009 class CL_BufferedSocket : public CL_Socket 00010 //: Non-blocked, buffered socket transmission interface. 00011 // The buffered socket class works like a socket in non-blocking mode, with a few exceptions: 00012 // <ul> 00013 // <li>any write operation will always write the full data. Any data not immidiately writeable 00014 // to the socket will be buffered and written in a seperate thread as the socket can receive 00015 // them. When all the data has been written, the write event will trigger.</li> 00016 // 00017 // <li>incoming data is also buffered. Each time the input buffer has been filled (which 00018 // can be changed with set_input_buffer_size(int size), the read event will trigger.</li> 00019 // </ul> 00020 // Using this class, you can easilly write and read data in the chunk sizes you prefer. 00021 { 00023 public: 00024 CL_BufferedSocket(int socket); 00025 // Constructs an attached socket. 00026 00027 CL_BufferedSocket(Type type); 00028 // Constructs a new socket using the specified protocol type. 00029 00030 CL_BufferedSocket(const CL_Socket &socket); 00031 // Create socket that is attached to the passed socket. 00032 // Note that since the buffered socket class will read data from the socket (buffering it), 00033 // it will no longer be safe to use the original socket until the buffered socket instance 00034 // has been destroyed. 00035 00036 CL_BufferedSocket(const CL_BufferedSocket ©); 00037 // Copy constructor. 00038 00039 virtual ~CL_BufferedSocket(); 00040 00042 public: 00043 int get_input_buffer_size() const; 00044 // Returns the size of the buffered input buffer. Each time it is full, 00045 // the read event will trigger. 00046 00048 public: 00049 void set_input_buffer_size(int size); 00050 // Sets the size of the buffered input buffer. Each time it is full, 00051 // the read event will trigger. 00052 00054 private: 00055 class CL_BufferedSocket_Generic *impl; 00056 }; 00057 00058 #endif
1.2.6 written by Dimitri van Heesch,
© 1997-2001