#include <sockbuf.h>
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_sockbuf * | close () 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. | |
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.
| socklibpp::basic_sockbuf< _CharT, _Traits >::basic_sockbuf | ( | sock | sock_ | ) | [inline, explicit] |
Constructor taking a socklibpp::sock argument.
| bool socklibpp::basic_sockbuf< _CharT, _Traits >::connect | ( | const addr_in & | _sin | ) | throw () [inline] |
Establish a connection.
| bool socklibpp::basic_sockbuf< _CharT, _Traits >::connect | ( | const std::string & | _addr, | |
| uint16_t | _port | |||
| ) | throw () [inline] |
Establish a connection.
| _addr | The host name or ip | |
| _port | The host port |
| 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.
| 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. |
| ios_base::failure | if an error occurred. |
| 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.
| _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. |
| ios_base::failure | if an error occurred. |
| 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.
| _n | The size of the internal input and output buffer. Both will have the size _n each, so they sum up _n*2 bytes. |
1.5.1