ucommon/buffer.h

Go to the documentation of this file.
00001 // Copyright (C) 2006-2010 David Sugar, Tycho Softworks.
00002 //
00003 // This file is part of GNU uCommon C++.
00004 //
00005 // GNU uCommon C++ is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU Lesser General Public License as published
00007 // by the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // GNU uCommon C++ is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with GNU uCommon C++.  If not, see <http://www.gnu.org/licenses/>.
00017 
00023 #ifndef _UCOMMON_BUFFER_H_
00024 #define _UCOMMON_BUFFER_H_
00025 
00026 #ifndef _UCOMMON_CONFIG_H_
00027 #include <ucommon/platform.h>
00028 #endif
00029 
00030 #ifndef _UCOMMON_PROTOCOLS_H_
00031 #include <ucommon/protocols.h>
00032 #endif
00033 
00034 #ifndef _UCOMMON_SOCKET_H_
00035 #include <ucommon/socket.h>
00036 #endif
00037 
00038 #ifndef _UCOMMON_STRING_H_
00039 #include <ucommon/string.h>
00040 #endif
00041 
00042 #ifndef _UCOMMON_FSYS_H_
00043 #include <ucommon/fsys.h>
00044 #endif
00045 
00046 #ifndef _UCOMMON_SHELL_H_
00047 #include <ucommon/shell.h>
00048 #endif
00049 
00050 NAMESPACE_UCOMMON
00051 
00058 class __EXPORT TCPBuffer : public BufferProtocol, protected Socket
00059 {
00060 protected:
00061     void _buffer(size_t size);
00062 
00063     virtual size_t _push(const char *address, size_t size);
00064     virtual size_t _pull(char *address, size_t size);
00065     int _err(void) const;
00066     void _clear(void);
00067     bool _blocking(void);
00068 
00073     inline socket_t getsocket(void) const
00074         {return so;};
00075 
00076 public:
00080     TCPBuffer();
00081 
00087     TCPBuffer(const TCPServer *server, size_t size = 536);
00088 
00095     TCPBuffer(const char *host, const char *service, size_t size = 536);
00096 
00100     virtual ~TCPBuffer();
00101 
00108     void open(const TCPServer *server, size_t size = 536);
00109 
00117     void open(const char *host, const char *service, size_t size = 536);
00118 
00122     void close(void);
00123 
00124 protected:
00129     virtual bool _pending(void);
00130 };
00131 
00135 typedef TCPBuffer tcp_t;
00136 
00137 END_NAMESPACE
00138 
00139 #endif

Generated on 14 Aug 2013 for UCommon by  doxygen 1.4.7