UCommon
buffer.h
Go to the documentation of this file.
1 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks.
2 // Copyright (C) 2015 Cherokees of Idaho.
3 //
4 // This file is part of GNU uCommon C++.
5 //
6 // GNU uCommon C++ is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU Lesser General Public License as published
8 // by the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // GNU uCommon C++ is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>.
18 
24 #ifndef _UCOMMON_BUFFER_H_
25 #define _UCOMMON_BUFFER_H_
26 
27 #ifndef _UCOMMON_CONFIG_H_
28 #include <ucommon/platform.h>
29 #endif
30 
31 #ifndef _UCOMMON_PROTOCOLS_H_
32 #include <ucommon/protocols.h>
33 #endif
34 
35 #ifndef _UCOMMON_SOCKET_H_
36 #include <ucommon/socket.h>
37 #endif
38 
39 #ifndef _UCOMMON_STRING_H_
40 #include <ucommon/string.h>
41 #endif
42 
43 #ifndef _UCOMMON_FSYS_H_
44 #include <ucommon/fsys.h>
45 #endif
46 
47 #ifndef _UCOMMON_SHELL_H_
48 #include <ucommon/shell.h>
49 #endif
50 
51 namespace ucommon {
52 
59 class __EXPORT TCPBuffer : public BufferProtocol, protected Socket
60 {
61 protected:
62  void _buffer(size_t size);
63 
64  virtual size_t _push(const char *address, size_t size);
65  virtual size_t _pull(char *address, size_t size);
66  int _err(void) const;
67  void _clear(void);
68  bool _blocking(void);
69 
74  inline socket_t getsocket(void) const {
75  return so;
76  }
77 
78 public:
82  TCPBuffer();
83 
89  TCPBuffer(const TCPServer *server, size_t size = 536);
90 
97  TCPBuffer(const char *host, const char *service, size_t size = 536);
98 
102  virtual ~TCPBuffer();
103 
110  void open(const TCPServer *server, size_t size = 536);
111 
119  void open(const char *host, const char *service, size_t size = 536);
120 
124  void close(void);
125 
126 protected:
131  virtual bool _pending(void);
132 };
133 
137 typedef TCPBuffer tcp_t;
138 
139 } // namespace ucommon
140 
141 #endif
A common string class and character string support functions.
socket_t getsocket(void) const
Get the low level socket object.
Definition: buffer.h:74
TCPBuffer tcp_t
Convenience type for pure tcp sockets.
Definition: buffer.h:137
Various miscellaneous platform specific headers and defines.
Thread-aware file system manipulation class.
A generic tcp socket class that offers i/o buffering.
Definition: buffer.h:59
A generic socket base class.
Definition: socket.h:322
Common buffer protocol class.
Definition: protocols.h:292
Common socket class and address manipulation.
Common namespace for all ucommon objects.
Definition: access.h:47
Abstract interfaces and support.
A generic tcp server class.
Definition: socket.h:1861
Generic shell parsing and application services.
A generic socket address class.
Definition: socket.h:359