#include <wvencoderstream.h>
Inherits WvStreamClone.
Inherited by WvBlowfishStream, WvGzipStream, WvRSAStream, WvTripleDESStream, and WvXORStream.
Collaboration diagram for WvEncoderStream:
Notice that the value of WvEncoderStream's auto_flush flag becomes important when working with encoders that treat explicit buffer flushing in a special manner. For instance, on flush() the Gzip encoder synchronizes its output. Were auto_flush to remain true, each incremental write to the stream would cause the Gzip encoder to flush its dictionary thereby resulting in poor compression.
Definition at line 28 of file wvencoderstream.h.
Public Member Functions | |
WvEncoderStream (WvStream *cloned) | |
Creates an encoder stream. | |
virtual | ~WvEncoderStream () |
virtual void | close () |
Safely shuts down the stream. | |
bool | flush_read () |
Flushes the read chain through to the stream's input buffer. | |
bool | flush_write () |
Flushes the write chain through to the stream's output buffer. | |
bool | finish_read () |
Calls flush() then finish() on the read chain of encoders. | |
bool | finish_write () |
Calls flush() then finish() on the write chain of encoders. | |
virtual bool | isok () const |
Defines isok() semantics for encoders. | |
virtual void | setclone (IWvStream *clone) |
virtual int | geterr () const |
If isok() is false, return the system error number corresponding to the error, -1 for a special error string (which you can obtain with errstr()) or 0 on end of file. | |
virtual WvString | errstr () const |
bool | pre_select (SelectInfo &si, const SelectRequest &r) |
A more convenient version of pre_select() usable for overriding the 'want' value temporarily. | |
virtual bool | post_select (SelectInfo &si) |
post_select() is called after ::select(), and returns true if this object is now ready. | |
bool | post_select (SelectInfo &si, const SelectRequest &r) |
A more convenient version of post_select() usable for overriding the 'want' value temporarily. | |
virtual const WvAddr * | src () const |
get the remote address from which the last data block was received. | |
virtual void | execute () |
The callback() function calls execute(), and then calls the user- specified callback if one is defined. | |
virtual void | nowrite () |
Shuts down the writing side of the stream. | |
virtual void | seterr (int _errnum) |
Override seterr() from WvError so that it auto-closes the stream. | |
void | seterr (WvStringParm specialerr) |
void | seterr (WVSTRING_FORMAT_DECL) |
void | seterr (const WvError &err) |
virtual size_t | read (void *buf, size_t count) |
read a data block on the stream. | |
virtual size_t | read (WvBuf &outbuf, size_t count) |
Reads up to 'count' bytes of data from the stream into the buffer. | |
virtual size_t | continue_read (time_t wait_msec, void *buf, size_t count) |
Read exactly count bytes from the stream. | |
virtual size_t | continue_read (time_t wait_msec, WvBuf &outbuf, size_t count) |
Read exactly count bytes from the stream, using continue_select(). | |
virtual void | unread (WvBuf &outbuf, size_t count) |
Puts data back into the stream's internal buffer. | |
virtual size_t | write (const void *buf, size_t count) |
Write data to the stream. | |
virtual size_t | write (WvBuf &inbuf, size_t count=INT_MAX) |
Writes data to the stream from the given buffer. | |
size_t | write (WvStringParm s) |
print a preformatted WvString to the stream. | |
void | outbuf_limit (size_t size) |
set the maximum size of outbuf, beyond which a call to write() will return 0. | |
virtual void | noread () |
Shuts down the reading side of the stream. | |
virtual bool | isreadable () |
Returns true if the stream is readable. | |
virtual bool | iswritable () |
Returns true if the stream is writable (without using the outbuf). | |
char * | getline (time_t wait_msec, char separator= '\n', int readahead=1024) |
read up to one line of data from the stream and return a pointer to the internal buffer containing this line. | |
void | queuemin (size_t count) |
force read() to not return any bytes unless 'count' bytes can be read at once. | |
void | drain () |
drain the input buffer (read and discard data until select(0) returns false) | |
void | delay_output (bool is_delayed) |
force write() to always buffer output. | |
void | auto_flush (bool is_automatic) |
if true, force write() to call flush() each time, the default behavour. | |
virtual bool | flush (time_t msec_timeout) |
flush the output buffer, if we can do it without delaying more than msec_timeout milliseconds at a time. | |
virtual bool | should_flush () |
Returns true if we want to flush the output buffer right now. | |
void | flush_then_close (int msec_timeout) |
flush the output buffer automatically as select() is called. | |
bool | xpre_select (SelectInfo &si, const SelectRequest &r) |
Like pre_select(), but still exists even if you override the other pre_select() in a subclass. | |
bool | xpost_select (SelectInfo &si, const SelectRequest &r) |
Like post_select(), but still exists even if you override the other post_select() in a subclass. | |
bool | select (time_t msec_timeout) |
Return true if any of the requested features are true on the stream. | |
bool | select (time_t msec_timeout, bool readable, bool writable, bool isex=false) |
This version of select() sets forceable==false, so we use the exact readable/writable/isexception options provided. | |
void | runonce (time_t msec_timeout=-1) |
Exactly the same as: if (select(timeout)) callback();. | |
void | force_select (bool readable, bool writable, bool isexception=false) |
Use force_select() to force one or more particular modes (readable, writable, or isexception) to true when selecting on this stream. | |
void | undo_force_select (bool readable, bool writable, bool isexception=false) |
Undo a previous force_select() - ie. | |
bool | continue_select (time_t msec_timeout) |
return to the caller from execute(), but don't really return exactly; this uses WvTaskMan::yield() to return to the caller of callback() without losing our place in execute() itself. | |
void | terminate_continue_select () |
you MUST run this from your destructor if you use continue_select(), or very weird things will happen if someone deletes your object while in continue_select(). | |
void | setcallback (WvStreamCallback _callfunc, void *_userdata) |
define the callback function for this stream, called whenever the callback() member is run, and passed the 'userdata' pointer. | |
void | setclosecallback (WvStreamCallback _callfunc, void *_userdata) |
Sets a callback to be invoked on close(). | |
void | autoforward (WvStream &s) |
set the callback function for this stream to an internal routine that auto-forwards all incoming stream data to the given output stream. | |
void | noautoforward () |
Stops autoforwarding. | |
virtual void | callback () |
if the stream has a callback function defined, call it now. | |
void | alarm (time_t msec_timeout) |
set an alarm, ie. | |
time_t | alarm_remaining () |
return the number of milliseconds remaining before the alarm will go off; -1 means no alarm is set (infinity), 0 means the alarm has been hit and will be cleared by the next callback(). | |
size_t | print (WvStringParm s) |
size_t | print (WVSTRING_FORMAT_DECL) |
preformat and write() a string. | |
size_t | operator() (WvStringParm s) |
size_t | operator() (WVSTRING_FORMAT_DECL) |
virtual unsigned int | addRef () |
virtual unsigned int | release () |
void | noerr () |
Reset our error state - there's no error condition anymore. | |
Static Public Member Functions | |
void | autoforward_callback (WvStream &s, void *userdata) |
Public Attributes | |
WvEncoderChain | readchain |
Encoder chain through which input data is passed. | |
WvEncoderChain | writechain |
Encoder chain through which output data is passed. | |
size_t | min_readsize |
Controls the minimum number of unencoded bytes the encoder should try to read at once from the underlying stream, to optimize performance of block-oriented protocols. | |
IWvStream * | cloned |
bool | disassociate_on_close |
SelectRequest | force |
'force' is the list of default SelectRequest values when you use the variant of select() that doesn't override them. | |
WvStream * | read_requires_writable |
If this is set, select() doesn't return true for read unless the given stream also returns true for write. | |
WvStream * | write_requires_readable |
If this is set, select() doesn't return true for write unless the given stream also returns true for read. | |
bool | uses_continue_select |
If this is set, enables the use of continue_select(). | |
size_t | personal_stack_size |
Specifies the stack size to reserve for continue_select(). | |
bool | alarm_was_ticking |
This will be true during callback execution if the callback was triggered by the alarm going off. | |
Static Public Attributes | |
const XUUID | XIID |
Protected Member Functions | |
bool | pre_select (SelectInfo &si) |
pre_select() sets up for eventually calling ::select(). | |
virtual size_t | uread (void *buf, size_t size) |
unbuffered I/O functions; these ignore the buffer, which is handled by read(). | |
virtual size_t | uwrite (const void *buf, size_t size) |
unbuffered I/O functions; these ignore the buffer, which is handled by write(). | |
virtual bool | flush_internal (time_t msec_timeout) |
bool | _build_selectinfo (SelectInfo &si, time_t msec_timeout, bool readable, bool writable, bool isexcept, bool forceable) |
int | _do_select (SelectInfo &si) |
bool | _process_selectinfo (SelectInfo &si, bool forceable) |
bool | flush_outbuf (time_t msec_timeout) |
virtual int | getrfd () const |
virtual int | getwfd () const |
Static Protected Member Functions | |
void | _callback (void *stream) |
actually do the callback for an arbitrary stream. | |
Protected Attributes | |
WvTaskMan * | taskman |
WvDynBuf | inbuf |
WvDynBuf | outbuf |
WvStreamCallback | callfunc |
WvStreamCallback | closecb_func |
void * | userdata |
void * | closecb_data |
size_t | max_outbuf_size |
bool | outbuf_delayed_flush |
bool | is_auto_flush |
bool | want_nowrite |
bool | want_to_flush |
bool | is_flushing |
size_t | queue_min |
time_t | autoclose_time |
WvTime | alarm_time |
WvTime | last_alarm_check |
bool | running_callback |
bool | wvstream_execute_called |
WvTask * | task |
int | errnum |
WvString | errstring |
Static Protected Attributes | |
WvStream * | globalstream = NULL |
|
Creates an encoder stream. "cloned" is the stream to wrap Definition at line 11 of file wvencoderstream.cc. References min_readsize. |
|
Definition at line 19 of file wvencoderstream.cc. References close(). |
|
Definition at line 699 of file wvstream.cc. References WvStream::globalstream, WvStream::isok(), and WvStream::pre_select(). |
|
actually do the callback for an arbitrary stream. This is a static function so we can pass it as a function pointer to WvTask functions. Definition at line 156 of file wvstream.cc. References WvStream::callfunc, WvStream::execute(), WvStream::running_callback, WvStream::userdata, and WvStream::wvstream_execute_called. Referenced by WvStream::callback(). |
|
Definition at line 736 of file wvstream.cc. References WvStream::seterr(). |
|
Definition at line 767 of file wvstream.cc. References WvStream::globalstream, WvStream::isok(), and WvStream::post_select(). |
|
Implements IObject. |
|
set an alarm, ie. select() will return true after this many ms. The alarm is cleared when callback() is called. Definition at line 826 of file wvstream.cc. References WvStream::alarm_time, msecadd(), and wvtime(). Referenced by UniClientGen::clientdelta(), WvStream::continue_read(), WvStream::continue_select(), UniClientGen::do_select(), WvHttpStream::execute(), itertest3(), WvDelayedCallback< InnerCallback >::operator()(), runtests(), WvFtpStream::WvFtpStream(), WvHttpStream::WvHttpStream(), and WvTimeoutStream::WvTimeoutStream(). |
|
return the number of milliseconds remaining before the alarm will go off; -1 means no alarm is set (infinity), 0 means the alarm has been hit and will be cleared by the next callback().
Definition at line 835 of file wvstream.cc. References WvStream::alarm_time, WvStream::last_alarm_check, msecdiff(), tvdiff(), wvtime(), and WvTime. Referenced by WvStream::callback(), WvStreamList::pre_select(), WvStream::pre_select(), and WvIStreamList::pre_select(). |
|
if true, force write() to call flush() each time, the default behavour. otherwise, flush() is granted special meaning when explicitly invoked by the client and write() may empty the output buffer, but will not explicitly flush(). Definition at line 358 of file wvstream.h. References WvStream::is_auto_flush. |
|
set the callback function for this stream to an internal routine that auto-forwards all incoming stream data to the given output stream.
Definition at line 128 of file wvstream.cc. References WvStream::autoforward_callback(), WvStream::read_requires_writable, and WvStream::setcallback(). |
|
Definition at line 142 of file wvstream.cc. References WvStream::read(), and WvStream::write(). Referenced by WvStream::autoforward(). |
|
if the stream has a callback function defined, call it now. otherwise call execute(). Implements IWvStream. Definition at line 178 of file wvstream.cc. References WvStream::_callback(), WvStream::alarm_remaining(), WvStream::alarm_time, WvStream::alarm_was_ticking, WvTaskMan::get(), WvTask::isrunning(), WvStream::personal_stack_size, WvTaskMan::run(), WvTask::start(), WvTaskMan::start(), WvStream::task, WvStream::taskman, TRACE, and WvStream::uses_continue_select. Referenced by UniClientGen::do_select(), WvStreamList::execute(), fcopy(), main(), WvStream::runonce(), and runtests(). |
|
Safely shuts down the stream. Does the following in sequence:
Reimplemented from WvStreamClone. Definition at line 25 of file wvencoderstream.cc. References WvStreamClone::close(), finish_read(), and finish_write(). Referenced by ~WvEncoderStream(). |
|
Read exactly count bytes from the stream, using continue_select().
Definition at line 298 of file wvstream.cc. References WvBufBaseCommonImpl< T >::alloc(), WvStream::continue_read(), WvBufBaseCommonImpl< T >::free(), WvBufBaseCommonImpl< T >::unalloc(), and WvBuf. |
|
Read exactly count bytes from the stream. Notes: must be using continue_select to use this function. if timeout strikes or !isok() before count bytes could be read, nothing is read and 0 is returned. resets queuemin to 0. FIXME: yes, that means if the stream closes, continue_read might not read the last bit of data. You can use read() for that if you want. Definition at line 362 of file wvstream.cc. References WvStream::alarm(), WvStream::continue_select(), WvStream::isok(), WvStream::queuemin(), WvStream::read(), and WvStream::uses_continue_select. Referenced by WvStream::continue_read(). |
|
return to the caller from execute(), but don't really return exactly; this uses WvTaskMan::yield() to return to the caller of callback() without losing our place in execute() itself. So, next time someone calls callback(), it will be as if continue_select() returned. NOTE: execute() will won't be called recursively this way, but any other member function might get called, or member variables changed, or the state of the world updated while continue_select() runs. Don't assume that nothing has changed after a call to continue_select(). NOTE 2: if you're going to call continue_select(), you should set uses_continue_select=true before the first call to callback(). Otherwise your WvTask struct won't get created. NOTE 3: if msec_timeout >= 0, this uses WvStream::alarm(). Definition at line 856 of file wvstream.cc. References WvStream::alarm(), WvStream::alarm_was_ticking, WvStream::running_callback, WvStream::select(), WvStream::task, WvStream::taskman, TRACE, WvStream::uses_continue_select, WvTaskMan::whoami(), and WvTaskMan::yield(). Referenced by WvStream::continue_read(), and WvStream::getline(). |
|
force write() to always buffer output. This can be more efficient if you write a lot of small segments and want to "coagulate" them automatically. To flush the output buffer, use flush() or select(). Definition at line 346 of file wvstream.h. References WvStream::outbuf_delayed_flush, and WvStream::want_to_flush. Referenced by WvHTTPStream::pre_select(). |
|
drain the input buffer (read and discard data until select(0) returns false)
Definition at line 541 of file wvstream.cc. References WvStream::isreadable(), and WvStream::read(). Referenced by WvModemBase::hangup(), and WvDsp::pre_select(). |
|
Reimplemented from WvError. Reimplemented in WvHTTPStream. Definition at line 118 of file wvstreamclone.cc. References WvStreamClone::cloned, and WvError::errstr(). Referenced by WvHTTPStream::errstr(), WvHttpStream::~WvHttpStream(), and WvSSLStream::~WvSSLStream(). |
|
The callback() function calls execute(), and then calls the user- specified callback if one is defined. Do not call execute() directly; call callback() instead. The default execute() function does nothing. Note: If you override this function in a derived class, you must call the parent execute() yourself from the derived class. Reimplemented from WvStream. Reimplemented in WvUrlStream, WvHttpStream, WvFtpStream, WvProtoStream, UniConfDaemonConn, and MySocket. Definition at line 221 of file wvstreamclone.cc. References IWvStream::callback(), WvStreamClone::cloned, and WvStream::execute(). Referenced by WvProtoStream::execute(), WvHttpStream::execute(), WvFtpStream::execute(), and UniConfDaemonConn::execute(). |
|
Calls flush() then finish() on the read chain of encoders. Returns: true if the encoder chain returned true Definition at line 94 of file wvencoderstream.cc. References WvEncoder::finish(), WvEncoder::flush(), WvBufBaseCommonImpl< T >::merge(), and readchain. Referenced by close(). |
|
Calls flush() then finish() on the write chain of encoders. Does not flush() the stream. Returns: true if the encoder chain returned true. Definition at line 106 of file wvencoderstream.cc. Referenced by close(). |
|
flush the output buffer, if we can do it without delaying more than msec_timeout milliseconds at a time. (-1 means wait forever) Returns true if the flushing finished (the output buffer is empty). Implements IWvStream. Definition at line 549 of file wvstream.cc. References WvStream::flush_internal(), WvStream::flush_outbuf(), WvStream::is_flushing, TRACE, and WvStream::want_to_flush. Referenced by WvStream::close(), flush_internal(), WvStream::flush_then_close(), WvStreamClone::post_select(), and WvStream::write(). |
|
Reimplemented from WvStreamClone. Definition at line 59 of file wvencoderstream.cc. References WvStream::flush(), flush_write(), isok(), WvStream::select(), and WvBufBaseCommonImpl< T >::used(). |
|
|
Flushes the read chain through to the stream's input buffer. The regular stream flush() only operates on the write chain. Returns: true if the encoder chain returned true Definition at line 78 of file wvencoderstream.cc. References WvEncoder::flush(), WvBufBaseCommonImpl< T >::merge(), and readchain. |
|
flush the output buffer automatically as select() is called. If the buffer empties, close the stream. If msec_timeout seconds pass, close the stream. After the stream closes, it will become !isok() (and a WvStreamList can delete it automatically) Definition at line 653 of file wvstream.cc. References WvStream::autoclose_time, WvStream::flush(), WvStream::outbuf, TRACE, and WvBufBaseCommonImpl< T >::used(). Referenced by main(). |
|
Flushes the write chain through to the stream's output buffer. The regular stream flush() invokes this, then attempts to synchronously push the buffered data to the stream, which may not always be desirable since it can be quite costly. To simply cause the write chain to be flushed but allow WvStreams to drain the encoded output buffer at its leisure, use this function. Returns: true if the encoder chain returned true Definition at line 87 of file wvencoderstream.cc. Referenced by flush_internal(). |
|
Use force_select() to force one or more particular modes (readable, writable, or isexception) to true when selecting on this stream. If an option is set 'true', we will select on that option when someone does a select(). If it's set 'false', we don't change its force status. (To de-force something, use undo_force_select().) Definition at line 810 of file wvstream.cc. References WvStream::force. Referenced by WvSSLStream::WvSSLStream(), and WvStreamClone::WvStreamClone(). |
|
If isok() is false, return the system error number corresponding to the error, -1 for a special error string (which you can obtain with errstr()) or 0 on end of file. If isok() is true, returns an undefined number. Reimplemented from WvError. Reimplemented in WvHTTPStream. Definition at line 108 of file wvstreamclone.cc. References WvStreamClone::cloned, and WvError::geterr(). Referenced by WvHttpStream::close(), WvFtpStream::close(), WvHTTPStream::geterr(), WvHttpStream::~WvHttpStream(), and WvSSLStream::~WvSSLStream(). |
|
read up to one line of data from the stream and return a pointer to the internal buffer containing this line. If the end-of-line 'separator' is encountered, it is removed from the string. If wait_msec times out before the end of line is found, returns NULL and the line may be returned next time, or you can read what we have so far by calling read(). If wait_msec < 0, waits forever for a newline (often a bad idea!) If wait_msec=0, never waits. Otherwise, waits up to wait_msec milliseconds until a newline appears. Readahead specifies the maximum amount of data that the stream is allowed to read in one shot. It is expected that there will be no NULL characters on the line. If uses_continue_select is true, getline() will use continue_select() rather than select() to wait for its timeout. Definition at line 460 of file wvstream.cc. References WvBufBaseCommonImpl< T >::alloc(), WvStream::continue_select(), WvBufBaseCommonImpl< T >::get(), WvStream::inbuf, WvStream::isok(), msecadd(), msecdiff(), WvBufBaseCommonImpl< T >::mutablepeek(), WvBufBase< unsigned char >::put(), WvStream::queuemin(), WvStream::select(), WvBufBase< unsigned char >::strchr(), WvBufBaseCommonImpl< T >::unalloc(), WvStream::uread(), WvBufBaseCommonImpl< T >::used(), and wvtime(). Referenced by concallback(), WvProtoStream::execute(), WvHttpStream::execute(), WvFtpStream::execute(), WvIPRouteList::get_kernel(), WvConf::load_file(), WvLockDev::lock(), main(), mycallback(), WvLockFile::readpid(), UniIniGen::refresh(), WvInterfaceDict::update(), and WvHTTPStream::uread(). |
|
Implements IWvStream. Reimplemented in WvFDStream. Definition at line 641 of file wvstream.cc. |
|
Implements IWvStream. Reimplemented in WvFDStream. Definition at line 647 of file wvstream.cc. Referenced by WvStream::nowrite(), and WvSSLStream::uwrite(). |
|
Defines isok() semantics for encoders. Returns false on error or after all data has been read from the internal buffers and readchain.isfinished() or ! writechain.isok(). Returns: true if it is still possible to read and write data Reimplemented from WvStreamClone. Definition at line 42 of file wvencoderstream.cc. References WvError::geterr(), and WvStream::isok(). Referenced by flush_internal(). |
|
Returns true if the stream is readable.
Implements IWvStream. Definition at line 448 of file wvstream.cc. References WvStream::isok(), and WvStream::select(). Referenced by WvStream::drain(). |
|
Returns true if the stream is writable (without using the outbuf).
Implements IWvStream. Definition at line 454 of file wvstream.cc. References WvStream::isok(), and WvStream::select(). |
|
Stops autoforwarding.
Definition at line 135 of file wvstream.cc. References WvStream::read_requires_writable, and WvStream::setcallback(). |
|
Reset our error state - there's no error condition anymore.
|
|
Shuts down the reading side of the stream. Subsequent calls to read() will fail. Implements IWvStream. Reimplemented in WvFDStream. Definition at line 432 of file wvstream.cc. |
|
Shuts down the writing side of the stream. Subsequent calls to write() will fail. Reimplemented from WvStream. Definition at line 48 of file wvstreamclone.cc. References WvStreamClone::cloned, and IWvStream::nowrite(). |
|
Reimplemented in WvLog. Definition at line 624 of file wvstream.h. References WvStream::write(), and WVSTRING_FORMAT_CALL. |
|
Reimplemented in WvLog. Definition at line 618 of file wvstream.h. References WvStream::write(), and WvStringParm. Referenced by WvLog::operator()(). |
|
set the maximum size of outbuf, beyond which a call to write() will return 0. I need to do this for tape backups, since all I can do is write to the loopback as fast as I can, which causes us to run out of memory and get SIGABRT'd. (dcoombs: 12/15/2000) FIXME: there must be a better way. This confuses the semantics of write(); can you trust it to always write all the bytes, or not? Definition at line 273 of file wvstream.h. References WvStream::max_outbuf_size. |
|
A more convenient version of post_select() usable for overriding the 'want' value temporarily.
Definition at line 447 of file wvstream.h. References WvStream::post_select(). |
|
post_select() is called after ::select(), and returns true if this object is now ready. Usually this is done by checking for this object in the read, write, and except lists in the SelectInfo structure. If you want to do it in some other way, you should usually do it in pre_select() instead. You may also want to do extra maintenance functions here; for example, the standard WvStream::post_select tries to flush outbuf if it's nonempty. WvTCPConn might retry connect() if it's waiting for a connection to be established. Reimplemented from WvStream. Reimplemented in WvHttpStream, WvFtpStream, WvSSLStream, and WvSyncStream. Definition at line 171 of file wvstreamclone.cc. References WvStreamClone::cloned, WvStream::flush(), IWvStream::isok(), IWvStream::post_select(), WvStream::post_select(), WvStream::select(), IWvStream::should_flush(), and WvBufBaseCommonImpl< T >::used(). Referenced by WvSyncStream::post_select(), WvSSLStream::post_select(), WvHttpStream::post_select(), and WvFtpStream::post_select(). |
|
A more convenient version of pre_select() usable for overriding the 'want' value temporarily.
Definition at line 406 of file wvstream.h. References WvStream::pre_select(). |
|
pre_select() sets up for eventually calling ::select(). It adds the right fds to the read, write, and except lists in the SelectInfo struct. Returns true if we already know this stream is ready, and there's no need to actually do a real ::select(). Some streams, such as timers, can be implemented by _only_ either returning true or false here after doing a calculation, and never actually adding anything to the SelectInfo. You can add your stream to any of the lists even if readable, writable, or isexception isn't set. This is what force_select() does. You can also choose not to add yourself to the list if you know it would be useless right now. pre_select() is only called if isok() is true. pre_select() is allowed to reduce msec_timeout (or change it if it's -1). However, it's not allowed to _increase_ msec_timeout. Reimplemented from WvStreamClone. Definition at line 191 of file wvencoderstream.cc. References WvStreamClone::pre_select(), and WvBufBaseCommonImpl< T >::used(). |
|
preformat and write() a string.
Definition at line 622 of file wvstream.h. References WvStream::write(), and WVSTRING_FORMAT_CALL. |
|
Definition at line 616 of file wvstream.h. References WvStream::write(), and WvStringParm. Referenced by WvConf::addfile(), cmptest(), concallback(), do_addfile(), WvLogBuffer::dump(), WvConfigSection::dump(), WvLockFile::lock(), WvLockDev::lock(), main(), mycallback(), namelookup(), WvLog::operator()(), WvLog::perror(), WvHTTPStream::pre_select(), printkey(), printsection(), runtests(), WvConf::save(), test(), trymount(), and usage(). |
|
force read() to not return any bytes unless 'count' bytes can be read at once. (Useful for processing Content-Length headers, etc.) Use count==0 to disable this feature. WARNING: getline() sets queuemin to 0 automatically! Definition at line 332 of file wvstream.h. References WvStream::queue_min. Referenced by WvStream::continue_read(), and WvStream::getline(). |
|
Reads up to 'count' bytes of data from the stream into the buffer. Returns the actual amount read. If 'count' is greater than the amount of free space available in the buffer, only reads at most that amount. You should specify a reasonable upper bound on how much data should be read at once. Implements IWvStream. Definition at line 282 of file wvstream.cc. References WvBufBaseCommonImpl< T >::alloc(), WvBufBaseCommonImpl< T >::free(), WvBufBaseCommonImpl< T >::merge(), WvStream::read(), WvBufBaseCommonImpl< T >::unalloc(), WvBuf, and WvDynBuf. |
|
read a data block on the stream. Returns the actual amount read. Implements IWvStream. Definition at line 327 of file wvstream.cc. References WvBufBaseCommonImpl< T >::alloc(), WvBufBaseCommonImpl< T >::get(), WvStream::inbuf, WvStream::queue_min, TRACE, WvBufBaseCommonImpl< T >::unalloc(), WvStream::uread(), and WvBufBaseCommonImpl< T >::used(). Referenced by WvStream::autoforward_callback(), WvStream::continue_read(), WvStream::drain(), WvHttpStream::execute(), WvFtpStream::execute(), WvPipe::ignore_read(), main(), WvStream::read(), and WvHTTPStream::uread(). |
|
Implements IObject. |
|
Exactly the same as: if (select(timeout)) callback();. ...except that the above is deprecated, because it assumes callbacks aren't called automatically and that the return value of one-parameter select() is actually meaningful. Update your main loop to call runonce() instead of the above. Almost all modern programs should use msec_timeout = -1. Definition at line 492 of file wvstream.h. References WvStream::callback(), and WvStream::select(). |
|
This version of select() sets forceable==false, so we use the exact readable/writable/isexception options provided. You normally use this variant of select() when deciding whether you should read/write a particular stream. For example: if (stream.select(1000, true, false)) len = stream.read(buf, sizeof(buf)); This variant of select() is probably not what you want with most WvStreamLists, unless you know exactly what you're doing. WARNING: the difference between the one-parameter and multi-parameter versions of select() is *incredibly* confusing. Make sure you use the right one! DEPRECATED. Call isreadable() or iswritable() instead, if msec_timeout was going to be zero. Other values of msec_timeout are not really recommended anyway. Definition at line 516 of file wvstream.h. |
|
Return true if any of the requested features are true on the stream. If msec_timeout < 0, waits forever (bad idea!). ==0, does not wait. Otherwise, waits for up to msec_timeout milliseconds. **NOTE** select() is _not_ virtual! To change the select() behaviour of a stream, override the pre_select() and/or post_select() functions. This version of select() sets forceable==true, so force_select options are taken into account. You almost always use this version of select() with callbacks, like this: if (stream.select(1000)) stream.callback(); If you want to read/write the stream in question, try using the other variant of select(). DEPRECATED. Call runonce() instead. Definition at line 477 of file wvstream.h. Referenced by WvStream::continue_select(), UniClientGen::do_select(), fcopy(), flush_internal(), WvStream::flush_outbuf(), WvStream::getline(), WvModemBase::hangup(), WvStream::isreadable(), WvStream::iswritable(), main(), WvStreamClone::post_select(), WvFDStream::post_select(), WvHTTPStream::pre_select(), WvStream::runonce(), runtests(), and WvFileWatcher::uread(). |
|
define the callback function for this stream, called whenever the callback() member is run, and passed the 'userdata' pointer.
Definition at line 573 of file wvstream.h. References WvStream::callfunc, and WvStream::userdata. Referenced by WvUnixListener::accept_callback(), WvTCPListener::accept_callback(), WvUnixListener::auto_accept(), WvTCPListener::auto_accept(), WvStream::autoforward(), main(), WvStream::noautoforward(), runtests(), UniConfDaemon::setupsslsocket(), UniConfDaemon::setuptcpsocket(), UniConfDaemon::setupunixsocket(), UniClientGen::UniClientGen(), WvDelayedCallback< InnerCallback >::WvDelayedCallback(), and WvDelayedCallback< InnerCallback >::~WvDelayedCallback(). |
|
Definition at line 136 of file wvstreamclone.cc. References WvStreamClone::cloned, close_callback(), and IWvStream::setclosecallback(). Referenced by WvStreamClone::WvStreamClone(). |
|
Sets a callback to be invoked on close().
Implements IWvStream. Definition at line 577 of file wvstream.h. References WvStream::closecb_data, and WvStream::closecb_func. |
|
Definition at line 64 of file wverror.cc. References WvError::errstr(), WvError::geterr(), and WvError::seterr(). |
|
Reimplemented from WvError. Definition at line 202 of file wvstream.h. References WvStream::seterr(), and WVSTRING_FORMAT_CALL. |
|
Reimplemented from WvError. Definition at line 200 of file wvstream.h. References WvError::seterr(), and WvStringParm. |
|
Override seterr() from WvError so that it auto-closes the stream.
Reimplemented from WvError. Definition at line 272 of file wvstream.cc. References WvStream::close(), and WvError::seterr(). Referenced by WvStream::_do_select(), WvTCPConn::check_resolver(), WvTCPConn::do_connect(), WvHttpStream::execute(), WvFtpStream::execute(), WvConf::load_file(), WvFile::open(), WvTCPConn::post_select(), WvSSLStream::post_select(), WvHTTPStream::pre_select(), WvDsp::realtime(), WvStream::seterr(), WvSSLStream::uread(), WvHTTPStream::uread(), WvFDStream::uread(), WvUDPStream::uwrite(), WvSSLStream::uwrite(), WvIPRawStream::uwrite(), WvFDStream::uwrite(), WvDsp::WvDsp(), WvIPRawStream::WvIPRawStream(), WvSSLStream::WvSSLStream(), WvTCPListener::WvTCPListener(), WvUDPStream::WvUDPStream(), WvUnixConn::WvUnixConn(), and WvUnixListener::WvUnixListener(). |
|
Returns true if we want to flush the output buffer right now. This allows us to implement delayed_flush(), flush_then_close(), etc, but it's still super-ugly and probably needs to go away. (In fact, all our buffer flushing is super-ugly right now.) Implements IWvStream. Definition at line 566 of file wvstream.cc. Referenced by WvFDStream::post_select(), and WvStream::write(). |
|
get the remote address from which the last data block was received. May be NULL. The pointer becomes invalid upon the next call to read(). Reimplemented from WvStream. Definition at line 213 of file wvstreamclone.cc. References WvStreamClone::cloned, and IWvStream::src(). Referenced by WvPamStream::WvPamStream(). |
|
you MUST run this from your destructor if you use continue_select(), or very weird things will happen if someone deletes your object while in continue_select().
Definition at line 885 of file wvstream.cc. References WvStream::close(), WvTask::isrunning(), WvTask::recycle(), WvTaskMan::run(), WvStream::task, and WvStream::taskman. |
|
Undo a previous force_select() - ie. un-forces the options which are 'true', and leaves the false ones alone. Definition at line 818 of file wvstream.cc. References WvStream::force. Referenced by WvFile::open(), and WvSSLStream::post_select(). |
|
Puts data back into the stream's internal buffer. We cheat so that there's no restriction on how much (or what) data can be unread(). This is different from WvBuf::unget() (which is rather restrictive). Definition at line 904 of file wvstream.cc. References WvStream::inbuf, WvBufBaseCommonImpl< T >::merge(), WvBuf, WvDynBuf, and WvBufBaseCommonImpl< T >::zap(). |
|
unbuffered I/O functions; these ignore the buffer, which is handled by read(). Don't call these functions explicitly unless you have a _really_ good reason. This is what you would override in a derived class. Reimplemented from WvStreamClone. Definition at line 169 of file wvencoderstream.cc. References min_readsize, WvBufBase< unsigned char >::move(), and WvBufBaseCommonImpl< T >::used(). |
|
unbuffered I/O functions; these ignore the buffer, which is handled by write(). Don't call these functions explicitly unless you have a _really_ good reason. This is what you would override in a derived class. Reimplemented from WvStreamClone. Definition at line 183 of file wvencoderstream.cc. References WvBufBase< unsigned char >::put(). |
|
print a preformatted WvString to the stream. see the simple version of write() way up above. Definition at line 614 of file wvstream.h. References WvFastString::cstr(), WvFastString::len(), WvStream::write(), and WvStringParm. |
|
Writes data to the stream from the given buffer. Returns the actual amount written. If count is greater than the amount of data available in the buffer, only writes at most that amount. Implements IWvStream. Definition at line 314 of file wvstream.cc. References WvBufBaseCommonImpl< T >::get(), WvBufBaseCommonImpl< T >::unget(), WvBufBaseCommonImpl< T >::used(), WvStream::write(), and WvBuf. |
|
Write data to the stream. Returns the actual amount written. Since WvStream has an output buffer, it *always* successfully "writes" the full amount (but you might have to flush the buffers later so it actually gets sent). Implements IWvStream. Definition at line 397 of file wvstream.cc. References WvStream::flush(), WvStream::flush_outbuf(), WvStream::isok(), WvStream::max_outbuf_size, WvStream::outbuf, WvStream::outbuf_delayed_flush, WvBufBase< unsigned char >::put(), WvStream::should_flush(), WvBufBaseCommonImpl< T >::used(), and WvStream::uwrite(). Referenced by WvLogFileBase::_mid_line(), WvStream::autoforward_callback(), WvHttpStream::execute(), WvFtpStream::execute(), WvModemBase::hangup(), main(), WvStream::operator()(), WvLog::operator()(), WvStream::print(), WvProtoStream::uwrite(), WvDsp::uwrite(), WvStream::write(), and WvPamStream::WvPamStream(). |
|
Like post_select(), but still exists even if you override the other post_select() in a subclass. Sigh. Definition at line 440 of file wvstream.h. References WvStream::post_select(). |
|
Like pre_select(), but still exists even if you override the other pre_select() in a subclass. Sigh. Definition at line 419 of file wvstream.h. References WvStream::pre_select(). |
|
Definition at line 690 of file wvstream.h. Referenced by WvStream::alarm(), WvStream::alarm_remaining(), and WvStream::callback(). |
|
This will be true during callback execution if the callback was triggered by the alarm going off.
Definition at line 183 of file wvstream.h. Referenced by WvStream::callback(), UniClientGen::conncallback(), and WvStream::continue_select(). |
|
Definition at line 689 of file wvstream.h. Referenced by WvStream::flush_outbuf(), and WvStream::flush_then_close(). |
|
Definition at line 673 of file wvstream.h. Referenced by WvStream::_callback(), and WvStream::setcallback(). |
|
|
Definition at line 676 of file wvstream.h. Referenced by WvStream::close(), and WvStream::setclosecallback(). |
|
Definition at line 674 of file wvstream.h. Referenced by WvStream::close(), and WvStream::setclosecallback(). |
|
Definition at line 43 of file wvstreamclone.h. |
|
Definition at line 22 of file wverror.h. Referenced by WvError::errstr(), and WvError::seterr(). |
|
Definition at line 23 of file wverror.h. Referenced by WvError::errstr(), and WvError::seterr(). |
|
'force' is the list of default SelectRequest values when you use the variant of select() that doesn't override them.
Definition at line 159 of file wvstream.h. Referenced by WvStream::force_select(), and WvStream::undo_force_select(). |
|
Definition at line 38 of file wvstream.cc. Referenced by WvStream::_build_selectinfo(), and WvStream::_process_selectinfo(). |
|
Definition at line 672 of file wvstream.h. Referenced by WvStream::getline(), WvStream::pre_select(), WvStream::read(), and WvStream::unread(). |
|
Definition at line 679 of file wvstream.h. Referenced by WvStream::auto_flush(). |
|
Definition at line 686 of file wvstream.h. Referenced by WvStream::flush(). |
|
Definition at line 691 of file wvstream.h. Referenced by WvStream::alarm_remaining(). |
|
Definition at line 677 of file wvstream.h. Referenced by WvStream::outbuf_limit(), and WvStream::write(). |
|
Controls the minimum number of unencoded bytes the encoder should try to read at once from the underlying stream, to optimize performance of block-oriented protocols. This is not the same as queuemin() which guarantees how much encoded input must be generated before select() returns true. if 0, the encoder will only whatever is specified in uread() Definition at line 52 of file wvencoderstream.h. Referenced by uread(), and WvEncoderStream(). |
|
Definition at line 672 of file wvstream.h. Referenced by WvStream::flush_outbuf(), WvStream::flush_then_close(), and WvStream::write(). |
|
Definition at line 678 of file wvstream.h. Referenced by WvStream::delay_output(), and WvStream::write(). |
|
Specifies the stack size to reserve for continue_select().
Definition at line 177 of file wvstream.h. Referenced by WvStream::callback(). |
|
Definition at line 688 of file wvstream.h. Referenced by WvStream::queuemin(), and WvStream::read(). |
|
If this is set, select() doesn't return true for read unless the given stream also returns true for write.
Definition at line 165 of file wvstream.h. Referenced by WvStream::autoforward(), and WvStream::noautoforward(). |
|
Encoder chain through which input data is passed.
Definition at line 39 of file wvencoderstream.h. Referenced by finish_read(), and flush_read(). |
|
Definition at line 692 of file wvstream.h. Referenced by WvStream::_callback(), WvStream::continue_select(), and WvStream::~WvStream(). |
|
Definition at line 695 of file wvstream.h. Referenced by WvStream::callback(), WvStream::continue_select(), WvStream::terminate_continue_select(), and WvStream::~WvStream(). |
|
Definition at line 670 of file wvstream.h. Referenced by WvStream::callback(), WvStream::continue_select(), WvStream::terminate_continue_select(), and WvStream::~WvStream(). |
|
Definition at line 675 of file wvstream.h. Referenced by WvStream::_callback(), and WvStream::setcallback(). |
|
If this is set, enables the use of continue_select().
Definition at line 174 of file wvstream.h. Referenced by WvStream::callback(), WvStream::continue_read(), and WvStream::continue_select(). |
|
Definition at line 680 of file wvstream.h. Referenced by WvStream::nowrite(). |
|
Definition at line 683 of file wvstream.h. Referenced by WvStream::delay_output(), WvStream::flush(), and WvStream::flush_outbuf(). |
|
If this is set, select() doesn't return true for write unless the given stream also returns true for read.
Definition at line 171 of file wvstream.h. |
|
Encoder chain through which output data is passed.
Definition at line 42 of file wvencoderstream.h. |
|
Definition at line 693 of file wvstream.h. Referenced by WvStream::_callback(), and WvStream::execute(). |
|
Definition at line 139 of file wvstream.h. |