socklibpp::basic_sockbuf< _CharT, _Traits > Class Template Reference

basic_sockbuf template More...

#include <sockbuf.h>

List of all members.

Public Types

typedef _CharT char_type
typedef _Traits traits_type
typedef traits_type::int_type int_type
typedef traits_type::pos_type pos_type
typedef traits_type::off_type off_type
typedef std::basic_streambuf<
char_type, traits_type > 
__streambuf_type

Public Member Functions

 basic_sockbuf ()
 Default constructor.
 basic_sockbuf (sock sock_)
 Constructor taking a socklibpp::sock argument.
 basic_sockbuf (const addr_in &_sin)
 Convenience constructor, that establishes a connection to a remote host.
virtual ~basic_sockbuf ()
 Destructor that calls sync(), close() and deletes the buffer.
sock socket () const throw ()
 Get the socket.
void socket (sock sock_) throw ()
 Set the socket.
bool connect (const addr_in &_sin) throw ()
 Establish a connection.
bool connect (const std::string &_addr, uint16_t _port) throw ()
 Establish a connection.
basic_sockbufclose () throw ()
 Close the connection and release resources allocated by the socket.
bool can_read (uint32_t usec_=0, uint32_t sec_=0) throw (std::ios_base::failure)
 Check if the connection has data to be read.
bool can_write (uint32_t _usec=0, uint32_t _sec=0) throw (std::ios_base::failure)
 Check if the connection has space to write data.
bool is_connected () const throw ()
 Checks to see if the socket is connected.

Protected Member Functions

void _M_buffer_init (int _sz=1024)
void _M_buffer_delete ()
virtual int_type underflow ()
 Called when the input buffer is empty.
virtual int showmanyc ()
 Called to test how many bytes can be read in the next operation.
virtual int_type overflow (int_type __c=traits_type::eof())
 Called when the output buffer is full.
virtual int sync ()
 Send everything that is on the output buffer.
virtual __streambuf_type * setbuf (char_type *, std::streamsize _n)
 Sets the internal buffers to size n.

Protected Attributes

sock _M_socket
 The socket.
char * _M_ibuffer
 The input and output buffers.
char * _M_obuffer
int _M_buf_size
 The size of input and output buffers.


Detailed Description

template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
class socklibpp::basic_sockbuf< _CharT, _Traits >

basic_sockbuf template

This class is intended for stream-oriented sockets (sock_stream). It doesn't provide (yet) access to advanced sock_stream sockets handling (like OOB) because this is usally low-level.

It's not (currently) intended for non-blocking sockets.

See also:
sock


Constructor & Destructor Documentation

template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
socklibpp::basic_sockbuf< _CharT, _Traits >::basic_sockbuf ( sock  sock_  )  [inline, explicit]

Constructor taking a socklibpp::sock argument.

Note:
basic_sockbuf will now own the socklibpp::sock object, and will be responsible for opening and closing it.


Member Function Documentation

template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
bool socklibpp::basic_sockbuf< _CharT, _Traits >::connect ( const addr_in _sin  )  throw () [inline]

Establish a connection.

Returns:
true if the connection has been established

template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
bool socklibpp::basic_sockbuf< _CharT, _Traits >::connect ( const std::string &  _addr,
uint16_t  _port 
) throw () [inline]

Establish a connection.

Parameters:
_addr The host name or ip
_port The host port
Returns:
true if the connection has been established

template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
bool socklibpp::basic_sockbuf< _CharT, _Traits >::can_read ( uint32_t  usec_ = 0,
uint32_t  sec_ = 0 
) throw (std::ios_base::failure) [inline]

Check if the connection has data to be read.

Parameters:
usec_ microseconds to wait until the socket can be read.
sec_ seconds to wait until the socket can be read. Set to -1 if you want it to block.
Exceptions:
ios_base::failure if an error occurred.
See also:
socklibpp::sock::can_read()

template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
bool socklibpp::basic_sockbuf< _CharT, _Traits >::can_write ( uint32_t  _usec = 0,
uint32_t  _sec = 0 
) throw (std::ios_base::failure) [inline]

Check if the connection has space to write data.

Parameters:
_usec microseconds to wait until the socket can be written.
_sec seconds to wait until the socket can be written. Set to -1 if you want it to block.
Exceptions:
ios_base::failure if an error occurred.
See also:
socklibpp::sock::can_write()

template<typename _CharT, typename _Traits = std::char_traits<_CharT>>
virtual __streambuf_type* socklibpp::basic_sockbuf< _CharT, _Traits >::setbuf ( char_type *  ,
std::streamsize  _n 
) [inline, protected, virtual]

Sets the internal buffers to size n.

Can't use external buffers; both output and input are the same size. Doesn't support unbuffered input/output.

Parameters:
_n The size of the internal input and output buffer. Both will have the size _n each, so they sum up _n*2 bytes.


The documentation for this class was generated from the following file:
Generated on Thu Jan 18 19:26:35 2007 for socklib++ by  doxygen 1.5.1