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