claw
1.9.0
Toggle main menu visibility
Loading...
Searching...
No Matches
basic_socketbuf.hpp
Go to the documentation of this file.
1
/*
2
CLAW - a C++ Library Absolutely Wonderful
3
4
CLAW is a free library without any particular aim but being useful to
5
anyone.
6
7
Copyright (C) 2005-2011 Julien Jorge
8
9
This library is free software; you can redistribute it and/or
10
modify it under the terms of the GNU Lesser General Public
11
License as published by the Free Software Foundation; either
12
version 2.1 of the License, or (at your option) any later version.
13
14
This library is distributed in the hope that it will be useful,
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
Lesser General Public License for more details.
18
19
You should have received a copy of the GNU Lesser General Public
20
License along with this library; if not, write to the Free Software
21
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
23
contact: julien.jorge@stuff-o-matic.com
24
*/
31
#ifndef __CLAW_BASIC_SOCKETBUF_HPP__
32
#define __CLAW_BASIC_SOCKETBUF_HPP__
33
34
#include <
claw/net/basic_socket.hpp
>
35
36
#include <streambuf>
37
#include <string>
38
39
namespace
claw
40
{
41
namespace
net
42
{
48
template
<
typename
CharT,
typename
Traits>
49
class
basic_socketbuf
50
:
private
basic_socket
51
,
public
std::basic_streambuf<CharT, Traits>
52
{
53
public
:
55
typedef
CharT
char_type
;
56
58
typedef
Traits
traits_type
;
59
61
typedef
typename
traits_type::int_type
int_type
;
62
64
typedef
typename
traits_type::pos_type
pos_type
;
65
67
typedef
typename
traits_type::off_type
off_type
;
68
70
typedef
basic_socketbuf<char_type, traits_type>
self_type
;
71
72
public
:
73
basic_socketbuf(
int
read_limit = -1);
74
virtual
~basic_socketbuf();
75
76
self_type
*
open
(
const
std::string& addr,
int
port);
77
self_type
*
open
(
socket_traits::descriptor
d);
78
self_type
*
close
();
79
80
bool
is_open
()
const
;
81
82
void
set_read_time_limit(
int
read_limit);
83
84
protected
:
85
virtual
int
sync();
86
virtual
int_type
underflow();
87
virtual
int_type
overflow(
int_type
c = traits_type::eof());
88
89
private
:
90
bool
connect(
const
std::string& addr,
int
port);
91
92
void
create_buffers();
93
void
destroy_buffers();
94
95
bool
buffered()
const
;
96
97
private
:
100
int
m_read_limit;
101
103
char_type
* m_input_buffer;
104
106
size_t
m_input_buffer_size;
107
109
char_type
* m_output_buffer;
110
112
size_t
m_output_buffer_size;
113
115
static
const
size_t
s_buffer_size;
116
117
};
// class basic_socketbuf
118
}
119
}
120
121
#include <claw/net/basic_socketbuf.tpp>
122
123
#endif
// __CLAW_BASIC_SOCKETBUF_HPP__
basic_socket.hpp
Common interface for claw::net::basic_socketbuf and claw::net::socket_server.
claw::net::basic_socket::basic_socket
basic_socket()
Constructor.
Definition
basic_socket.cpp:36
claw::net::basic_socket::open
basic_socket * open()
Open the socket.
Definition
basic_socket.cpp:44
claw::net::basic_socket::close
basic_socket * close()
Close the socket.
Definition
basic_socket.cpp:60
claw::net::basic_socket::is_open
bool is_open() const
Tell if the socket is open.
Definition
basic_socket.cpp:78
claw::net::basic_socketbuf::traits_type
Traits traits_type
The traits carry some informations about the char_type.
Definition
basic_socketbuf.hpp:58
claw::net::basic_socketbuf::char_type
CharT char_type
The type of the characters in the stream.
Definition
basic_socketbuf.hpp:55
claw::net::basic_socketbuf::off_type
traits_type::off_type off_type
The type used to represent a delta in the positions.
Definition
basic_socketbuf.hpp:67
claw::net::basic_socketbuf::self_type
basic_socketbuf< char_type, traits_type > self_type
The type of this implementation.
Definition
basic_socketbuf.hpp:70
claw::net::basic_socketbuf::int_type
traits_type::int_type int_type
The type used to represent integers.
Definition
basic_socketbuf.hpp:61
claw::net::basic_socketbuf::pos_type
traits_type::pos_type pos_type
The type used to represent a position in the stream.
Definition
basic_socketbuf.hpp:64
claw::socket_traits_unix::descriptor
int descriptor
Type of the system description of the socket.
Definition
socket_traits_unix.hpp:54
claw::net
Network communications.
Definition
claw.hpp:82
claw
This is the main namespace.
Definition
application.hpp:50
lib
net
include
claw
net
basic_socketbuf.hpp
Generated by
1.17.0