Home | C-Bits Package Documentation | Project Page |
00001 /* ==================================================================== 00002 * The CBITS Software License, Version 1.0 00003 * 00004 * Copyright (c) 2002-2003 Bruce Lowery 00005 * All rights reserved 00006 * 00007 * Redistribution and use of this software, in source and binary forms, 00008 * with or without modification, are permitted provided that the above 00009 * copyright notice, this paragraph, and the following paragraph are 00010 * retained in each source code file. 00011 * 00012 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 00013 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00014 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00015 * DISCLAIMED. IN NO EVENT SHALL BRUCE LOWERY OR OTHER CONTRIBUTORS 00016 * TO THE CBITS LIBRARY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00017 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00018 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00019 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00020 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00021 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00022 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00023 * SUCH DAMAGE. 00024 * ==================================================================== 00025 */ 00026 #ifndef __SOCKSTREAMBUF_H__ 00027 #define __SOCKSTREAMBUF_H__ 00028 00029 #if defined( __GNUC__ ) && __GNUC__ < 3 00030 #include <streambuf.h> 00031 #else 00032 #include <streambuf> 00033 #endif 00034 00035 00036 namespace cbits { 00037 00038 class Socket; 00039 00040 00041 #ifdef WIN32 00042 00043 #include <winsock> 00044 // For building a DLL 00045 #ifdef BUILD_DLL 00046 #define EXPORT __declspec(dllexport) 00047 #else 00048 #define EXPORT 00049 #endif 00050 typedef SOCKET socket_t; 00051 00052 #else 00053 00054 #define EXPORT 00055 typedef int socket_t; 00056 00057 #endif 00058 00059 00060 class EXPORT sockstreambuf : public std::streambuf 00061 { 00062 00063 public: 00064 sockstreambuf(); 00065 sockstreambuf( const socket_t h ); 00066 sockstreambuf( Socket* s ); 00067 void set_handle( const socket_t h ); 00068 ~sockstreambuf(); 00069 00070 protected: 00071 virtual int underflow(); 00072 virtual int overflow( int c = EOF ); 00073 00074 private: 00075 static const int DFLT_BUF_SIZE = 1024; 00076 socket_t _h; 00077 Socket* _sock; 00078 char* _rbuf; 00079 char _charbuf[1]; 00080 00081 }; /* END OF sockstreambuf */ 00082 00083 }; 00084 00085 #endif 00086 00087 /* 00088 * $Id: sockstreambuf.h,v 1.5 2002/10/16 22:32:44 brulow Exp $ 00089 * 00090 * History: (Add nothing manually below) 00091 * ----------------------------------------------------------------------- 00092 * 00093 * $Log: sockstreambuf.h,v $ 00094 * Revision 1.5 2002/10/16 22:32:44 brulow 00095 * Improve doc, misc 00096 * 00097 * Revision 1.4 2002/10/14 21:08:00 brulow 00098 * *** empty log message *** 00099 * 00100 * Revision 1.3 2002/10/13 20:12:59 brulow 00101 * *** empty log message *** 00102 * 00103 * Revision 1.2 2002/09/27 22:04:16 brulow 00104 * Add history footer to all .h .cpp files 00105 * 00106 * 00107 */
|
|