libassa 3.5.1
|
#include <Socketbuf.h>
Public Member Functions | |
Socketbuf (Socket *s_) | |
virtual | ~Socketbuf () |
![]() | |
virtual | ~Streambuf () |
Streambuf * | pubsetbuf (char *s_, int n_) |
Set buffer. | |
int | pubsync () |
int | in_avail () |
This function returns the number of characters immediately available in the get area. | |
int | snextc () |
This function moves the get pointer forward one position, then returns the character after the get pointer's new position. | |
int | sbumpc () |
This function should probably have been called `‘sgetc’'. | |
int | sgetc () |
This function returns the character after the get pointer, or EOF if the get pointer is at the end of the sequence. | |
int | sgetn (char *b_, int len_) |
This function gets the next len_ characters following the get pointer, copying them to the char array pointed to by b_; it advances the get pointer past the last character fetched. | |
int | sputc (char c_) |
This function stores c just after the put pointer, and advances the pointer one position, possibly extending the sequence. | |
int | sputn (char *b_, int len_) |
From the location pointed to by ptr, stores exactly len characters after the put pointer, advancing the put pointer just past the last character. | |
void | unbuffered (int i_) |
If i_ is non-zero, then all IO operations are buffered. | |
int | unbuffered () |
![]() | |
io_ptrs () | |
void | dump () const |
Protected Member Functions | |
virtual int | sync () |
This function synchronizes the streambuf with its actual stream of characters. | |
virtual int | underflow () |
This function is called to supply characters for input (from some source) when the get area is empty, although it may be called at other times. | |
virtual int | overflow (int c_=EOF) |
This function is called to consume characters (flush them to output), typically when the put area is full and an attempt is made to store another character. | |
virtual int | showmanyc () |
The morphemes of showmanyc are "es-how-many-see", not "show-man-ic". | |
virtual int | doallocate () |
This function is called by allocate when unbuffered() is zero and base() is zero. | |
![]() | |
Streambuf () | |
The default constructor is protected for class Streambuf to asssure that only objects for classes derived from this class may be constructed. | |
Streambuf (const Streambuf &) | |
Streambuf & | operator= (const Streambuf &) |
char * | base () const |
Returns the lowest possible value for gptr() - the beginning of the get area. | |
char * | gptr () const |
Returns a pointer to the beginning of the get area, and thus to the next character to be fetched (if there are any). | |
char * | egptr () const |
Returns a pointer just past the end of the get area, the maximum possible value for gptr(). | |
void | setg (char *gbeg_, char *gnext_, char *gend_) |
Set get area pointers. | |
char * | pbase () const |
Returns a pointer to the beginning fo the space available for the put area, the lowest possible value for pptr(). | |
char * | pptr () const |
Returns a pointer to the beginning of the put area, and thus to the location of the next character that is stored (if possible). | |
char * | epptr () const |
Returns a pointer just past the end of the put area, the maximum possible value for pptr(). | |
void | setp (char *pbeg_, char *pend_) |
Set put area pointers. | |
void | pbump (int n_) |
Advances the next pointer for the output sequence by n_. | |
void | setb (char *b_, char *eb_, int del_) |
Establish the reserve area (buffer). | |
void | init () |
virtual Streambuf * | setbuf (char *p_, int len_) |
Performs an operation that is defined separately for each class derived from Streambuf. | |
virtual int | xsgetn (char *b_, int len_) |
Assigns up to len_ characters to successive elements of the array whose first element is designated by b_. | |
virtual int | uflow () |
Reads the characters from the input sequence, if possible, and moves the stream position past it, as follows: | |
virtual int | xsputn (const char *b_, int len_) |
Writes up to len_ characters to the output sequence as if by repeated calls to sputc (c). | |
Private Member Functions | |
int | flush_output () |
int | sys_read (char *b_, int len_) |
int | sys_write (char *b_, int len_) |
void | xput_char (char c_) |
Private Attributes | |
Socket * | m_s |
Reference to the Socket stream. | |
Additional Inherited Members | |
![]() | |
enum | { USER_BUF = 1 , UNBUFFERED = 2 , EOF_SEEN = 4 , ERR_SEEN = 8 } |
![]() | |
char * | m_read_base |
char * | m_read_ptr |
char * | m_read_end |
char * | m_write_base |
char * | m_write_ptr |
char * | m_write_end |
char * | m_buf_base |
char * | m_buf_end |
int | m_flags |
char | m_shortbuf [1] |
![]() | |
static const int | MAXTCPFRAMESZ = 65536 |
Size of the internal input/output buffer. | |
Definition at line 29 of file Socketbuf.h.
Socketbuf::Socketbuf | ( | Socket * | s_ | ) |
Definition at line 24 of file Socketbuf.cpp.
References ASSA::STRMBUFTRACE, trace_with_mask, and ASSA::Streambuf::unbuffered().
|
virtual |
Definition at line 58 of file Socketbuf.cpp.
References overflow(), ASSA::STRMBUFTRACE, and trace_with_mask.
|
protectedvirtual |
This function is called by allocate when unbuffered() is zero and base() is zero.
It attempts to make a buffer of suitable size available. On success it must call setb to establish the reserve area, then return a value greater than zero. On failure it returns EOF. The default behavior is to allocate a buffer using new.
Reimplemented from ASSA::Streambuf.
Definition at line 226 of file Socketbuf.cpp.
References DL, ASSA::io_ptrs::dump(), ASSA::io_ptrs::m_buf_base, ASSA::io_ptrs::m_flags, ASSA::io_ptrs::m_shortbuf, ASSA::Streambuf::MAXTCPFRAMESZ, ASSA::Streambuf::setb(), ASSA::Streambuf::setg(), ASSA::Streambuf::setp(), ASSA::STRMBUF, ASSA::STRMBUFTRACE, trace_with_mask, and ASSA::io_ptrs::UNBUFFERED.
Referenced by overflow(), and underflow().
|
private |
Definition at line 191 of file Socketbuf.cpp.
References ASSA::Streambuf::epptr(), ASSA::Streambuf::MAXTCPFRAMESZ, ASSA::Streambuf::pbase(), ASSA::Streambuf::pbump(), ASSA::Streambuf::pptr(), ASSA::Streambuf::setp(), ASSA::STRMBUFTRACE, sys_write(), trace_with_mask, and ASSA::Streambuf::unbuffered().
Referenced by overflow(), and sync().
This function is called to consume characters (flush them to output), typically when the put area is full and an attempt is made to store another character.
If c is not EOF, overflow must either store or consume the character, following those already in the put area. It returns EOF on error, any other value on success. The default behavior of the base class version is undefined, so each derived class must define its own overflow. The normal action for a derived class version is to consume the characters in the put area (those between pbase() and pptr()), call setp() to set up a new put area, then store c (using sputc()) if it is not EOF.
Reimplemented from ASSA::Streambuf.
Definition at line 161 of file Socketbuf.cpp.
References doallocate(), ASSA::io_ptrs::dump(), ASSA::Streambuf::epptr(), flush_output(), ASSA::Streambuf::pbase(), ASSA::Streambuf::pptr(), ASSA::STRMBUFTRACE, trace_with_mask, ASSA::Streambuf::unbuffered(), and xput_char().
Referenced by ~Socketbuf().
|
protectedvirtual |
The morphemes of showmanyc are "es-how-many-see",
not "show-man-ic".
Return an estimate of the number of characters available in the sequence, or -1. If it returns a positive value,
then successive calls to underflow() will not return EOF until at least that number of characters have been supplied.
If showmanyc() returns -1, then calls to underflow() or uflow() will fail. The intention is not only that these calls will not return EOF, but that they will return `‘immediately.’'
Reimplemented from ASSA::Streambuf.
Definition at line 42 of file Socketbuf.cpp.
References ASSA::Socket::getBytesAvail(), m_s, ASSA::STRMBUFTRACE, and trace_with_mask.
|
protectedvirtual |
This function synchronizes the streambuf with its actual stream of characters.
The derived class version should flush any characters in the put area to their final destination, and if possible give back any characters in the input buffer to their source. It should return EOF on any error, zero on success. The default behavior of the base class version is to return zero if there are no pending input or output characters (in_avail() and out_waiting() are both zero), and return EOF otherwise.
Reimplemented from ASSA::Streambuf.
Definition at line 34 of file Socketbuf.cpp.
References flush_output(), ASSA::STRMBUFTRACE, and trace_with_mask.
Definition at line 66 of file Socketbuf.cpp.
References DL, ASSA::get_errno(), ASSA::Socket::getHandler(), m_s, ASSA::STRMBUFTRACE, and trace_with_mask.
Referenced by underflow().
Definition at line 85 of file Socketbuf.cpp.
References DL, ASSA::Socket::getHandler(), m_s, ASSA::STRMBUFTRACE, and trace_with_mask.
Referenced by flush_output().
|
protectedvirtual |
This function is called to supply characters for input (from some source) when the get area is empty, although it may be called at other times.
If the get area is not empty, it should just return the first character (without advancing the get pointer). If the get area is empty, it should establish a new get area, aquire new input, and return the first character, if any. If no input characters are available, it should leave an empty get area and return EOF. The default behavior of the base class version is undefined, so each derived class must define its own underflow.
Reimplemented from ASSA::Streambuf.
Definition at line 104 of file Socketbuf.cpp.
References ASSA::Streambuf::base(), DL, doallocate(), ASSA::io_ptrs::dump(), ASSA::MemDump::dump_to_log(), ASSA::Streambuf::egptr(), ASSA::io_ptrs::EOF_SEEN, ASSA::get_errno(), ASSA::Streambuf::gptr(), ASSA::io_ptrs::m_flags, ASSA::Streambuf::MAXTCPFRAMESZ, ASSA::Streambuf::setg(), ASSA::STRMBUF, ASSA::STRMBUFTRACE, sys_read(), trace_with_mask, and ASSA::Streambuf::unbuffered().
Definition at line 50 of file Socketbuf.cpp.
References ASSA::Streambuf::pbump(), ASSA::Streambuf::pptr(), ASSA::STRMBUFTRACE, and trace_with_mask.
Referenced by overflow().
|
private |
Reference to the Socket stream.
Definition at line 51 of file Socketbuf.h.
Referenced by showmanyc(), sys_read(), and sys_write().