33 template<
typename CharT,
typename Traits>
43 template<
typename CharT,
typename Traits>
45 : m_read_limit(read_limit), m_input_buffer(NULL), m_input_buffer_size(0),
46 m_output_buffer(NULL), m_output_buffer_size(0)
55 template<
typename CharT,
typename Traits>
69 template<
typename CharT,
typename Traits>
72 (
const std::string& address,
int port )
79 if ( connect( address, port ) )
97 template<
typename CharT,
typename Traits>
128 template<
typename CharT,
typename Traits>
142 template<
typename CharT,
typename Traits>
154 template<
typename CharT,
typename Traits>
158 m_read_limit = read_limit;
166 template<
typename CharT,
typename Traits>
172 ssize_t write_count = 0;
173 ssize_t length = (this->pptr() - this->pbase()) *
sizeof(
char_type);
177 write_count = send(m_descriptor, static_cast<const char*>(this->pbase()),
180 if ( write_count >= 0 )
181 this->setp( m_output_buffer, m_output_buffer + m_output_buffer_size );
195 template<
typename CharT,
typename Traits>
203 ssize_t length = m_input_buffer_size *
sizeof(
char_type);
204 int_type result = traits_type::eof();
210 read_count = recv(m_descriptor, static_cast<char*>(m_input_buffer), length,
215 if ( read_count > 0 )
217 this->setg( m_input_buffer, m_input_buffer, m_input_buffer + read_count);
218 result = this->sgetc();
221 this->setg( m_input_buffer, m_input_buffer + m_input_buffer_size,
222 m_input_buffer + m_input_buffer_size );
232 template<
typename CharT,
typename Traits>
239 int_type result = traits_type::eof();
243 result = traits_type::not_eof(c);
245 if ( !traits_type::eq_int_type(c, traits_type::eof()) )
260 template<
typename CharT,
typename Traits>
262 (
const std::string& addr,
int port )
274 template<
typename CharT,
typename Traits>
280 m_input_buffer_size = m_output_buffer_size = s_buffer_size;
282 m_input_buffer =
new char_type[m_input_buffer_size];
283 m_output_buffer =
new char_type[m_output_buffer_size];
285 this->setg( m_input_buffer, m_input_buffer + m_input_buffer_size,
286 m_input_buffer + m_input_buffer_size );
287 this->setp( m_output_buffer, m_output_buffer + m_output_buffer_size );
295 template<
typename CharT,
typename Traits>
298 if ( m_input_buffer )
300 delete[] m_input_buffer;
301 m_input_buffer = NULL;
304 if ( m_output_buffer )
306 delete[] m_output_buffer;
307 m_output_buffer = NULL;
310 this->setg( NULL, NULL, NULL );
311 this->setp( NULL, NULL );
319 template<
typename CharT,
typename Traits>
322 return this->pbase() && this->pptr() && this->epptr()
323 && this->eback() && this->gptr() && this->egptr();