#include <wvstream.h>
Inheritance diagram for WvStream:
Public Methods | |
WvStream (int _fd) | |
virtual | ~WvStream () |
WvStream (const WvStream &s) | |
WvStream & | operator= (const WvStream &s) |
virtual void | close () |
virtual int | getrfd () const |
virtual int | getwfd () const |
int | getfd () const |
virtual bool | isok () const |
virtual int | geterr () const |
virtual const char * | errstr () const |
size_t | read (void *buf, size_t count) |
size_t | write (const void *buf, size_t count) |
void | outbuf_limit (size_t size) |
virtual size_t | uread (void *buf, size_t count) |
virtual size_t | uwrite (const void *buf, size_t count) |
char * | getline (time_t wait_msec, char separator='\n') |
void | queuemin (size_t count) |
void | drain () |
void | delay_output (bool is_delayed) |
void | flush (time_t msec_timeout) |
void | flush_then_close (int msec_timeout) |
virtual bool | pre_select (SelectInfo &si) |
bool | pre_select (SelectInfo &si, const SelectRequest &r) |
virtual bool | post_select (SelectInfo &si) |
bool | post_select (SelectInfo &si, const SelectRequest &r) |
bool | select (time_t msec_timeout) |
bool | select (time_t msec_timeout, bool readable, bool writable, bool isex=false) |
void | force_select (bool readable, bool writable, bool isexception=false) |
void | undo_force_select (bool readable, bool writable, bool isexception=false) |
bool | continue_select (time_t msec_timeout) |
void | terminate_continue_select () |
virtual const WvAddr * | src () const |
void | setcallback (WvStreamCallback _callfunc, void *_userdata) |
void | autoforward (WvStream &s) |
void | callback () |
void | alarm (time_t msec_timeout) |
time_t | alarm_remaining () |
size_t | write (const WvString &s) |
size_t | print (const WvString &s) |
size_t | print (const WvString &__wvs_format, const WvString &__wvs_a0, const WvString &__wvs_a1=__wvs_n, const WvString &__wvs_a2=__wvs_n, const WvString &__wvs_a3=__wvs_n, const WvString &__wvs_a4=__wvs_n, const WvString &__wvs_a5=__wvs_n, const WvString &__wvs_a6=__wvs_n, const WvString &__wvs_a7=__wvs_n, const WvString &__wvs_a8=__wvs_n, const WvString &__wvs_a9=__wvs_n, const WvString &__wvs_a10=__wvs_n, const WvString &__wvs_a11=__wvs_n, const WvString &__wvs_a12=__wvs_n, const WvString &__wvs_a13=__wvs_n, const WvString &__wvs_a14=__wvs_n, const WvString &__wvs_a15=__wvs_n, const WvString &__wvs_a16=__wvs_n, const WvString &__wvs_a17=__wvs_n, const WvString &__wvs_a18=__wvs_n, const WvString &__wvs_a19=__wvs_n) |
size_t | operator() (const WvString &s) |
size_t | operator() (const WvString &__wvs_format, const WvString &__wvs_a0, const WvString &__wvs_a1=__wvs_n, const WvString &__wvs_a2=__wvs_n, const WvString &__wvs_a3=__wvs_n, const WvString &__wvs_a4=__wvs_n, const WvString &__wvs_a5=__wvs_n, const WvString &__wvs_a6=__wvs_n, const WvString &__wvs_a7=__wvs_n, const WvString &__wvs_a8=__wvs_n, const WvString &__wvs_a9=__wvs_n, const WvString &__wvs_a10=__wvs_n, const WvString &__wvs_a11=__wvs_n, const WvString &__wvs_a12=__wvs_n, const WvString &__wvs_a13=__wvs_n, const WvString &__wvs_a14=__wvs_n, const WvString &__wvs_a15=__wvs_n, const WvString &__wvs_a16=__wvs_n, const WvString &__wvs_a17=__wvs_n, const WvString &__wvs_a18=__wvs_n, const WvString &__wvs_a19=__wvs_n) |
WvStream (int _fd) | |
virtual | ~WvStream () |
WvStream (const WvStream &s) | |
WvStream & | operator= (const WvStream &s) |
virtual void | close () |
virtual int | getrfd () const |
virtual int | getwfd () const |
int | getfd () const |
virtual bool | isok () const |
virtual int | geterr () const |
virtual const char * | errstr () const |
size_t | read (void *buf, size_t count) |
size_t | write (const void *buf, size_t count) |
void | outbuf_limit (size_t size) |
virtual size_t | uread (void *buf, size_t count) |
virtual size_t | uwrite (const void *buf, size_t count) |
char * | getline (time_t wait_msec, char separator='\n') |
void | queuemin (size_t count) |
void | drain () |
void | delay_output (bool is_delayed) |
void | flush (time_t msec_timeout) |
void | flush_then_close (int msec_timeout) |
virtual bool | pre_select (SelectInfo &si) |
bool | pre_select (SelectInfo &si, const SelectRequest &r) |
virtual bool | post_select (SelectInfo &si) |
bool | post_select (SelectInfo &si, const SelectRequest &r) |
bool | select (time_t msec_timeout) |
bool | select (time_t msec_timeout, bool readable, bool writable, bool isex=false) |
void | force_select (bool readable, bool writable, bool isexception=false) |
void | undo_force_select (bool readable, bool writable, bool isexception=false) |
bool | continue_select (time_t msec_timeout) |
void | terminate_continue_select () |
virtual const WvAddr * | src () const |
void | setcallback (WvStreamCallback _callfunc, void *_userdata) |
void | autoforward (WvStream &s) |
void | callback () |
void | alarm (time_t msec_timeout) |
time_t | alarm_remaining () |
size_t | write (const WvString &s) |
size_t | print (const WvString &s) |
size_t | print (WVSTRING_FORMAT_DECL) |
size_t | operator() (const WvString &s) |
size_t | operator() (WVSTRING_FORMAT_DECL) |
Static Public Methods | |
void | autoforward_callback (WvStream &s, void *userdata) |
void | autoforward_callback (WvStream &s, void *userdata) |
Public Attributes | |
SelectRequest | force |
WvStream * | read_requires_writable |
WvStream * | write_requires_readable |
bool | uses_continue_select |
size_t | personal_stack_size |
WvStream * | read_requires_writable |
WvStream * | write_requires_readable |
Protected Methods | |
WvStream () | |
void | seterr (int _errnum) |
void | seterr (const WvString &specialerr) |
virtual void | execute () |
WvStream () | |
void | seterr (int _errnum) |
void | seterr (const WvString &specialerr) |
virtual void | execute () |
Static Protected Methods | |
void | _callback (void *stream) |
void | _callback (void *stream) |
Protected Attributes | |
WvStreamCallback | callfunc |
void * | userdata |
int | rwfd |
int | errnum |
WvString | errstring |
WvBuffer | inbuf |
WvBuffer | outbuf |
size_t | max_outbuf_size |
bool | outbuf_delayed_flush |
bool | alarm_was_ticking |
size_t | queue_min |
time_t | autoclose_time |
timeval | alarm_time |
bool | running_callback |
WvTask * | task |
void * | userdata |
timeval | alarm_time |
WvTask * | task |
Static Protected Attributes | |
WvTaskMan * | taskman |
WvTaskMan * | taskman |
Private Methods | |
void | init () |
bool | _select (time_t msec_timeout, bool readable, bool writable, bool isexcept, bool forceable) |
void | init () |
bool | _select (time_t msec_timeout, bool readable, bool writable, bool isexcept, bool forceable) |
Private Attributes | |
bool | wvstream_execute_called |
We provide typical read and write routines, as well as a select() function for each stream.
Definition at line 30 of file include/wvstream.h.
|
constructor to create a WvStream from an existing file descriptor. The file descriptor is closed automatically by the destructor. If this is undesirable, duplicate it first using dup(). Definition at line 35 of file wvstream.cc. |
|
Definition at line 64 of file wvstream.cc. References close(), WvTask::isrunning(), WvTask::recycle(), WvTaskMan::run(), running_callback, task, taskman, and TRACE. |
|
copy constructor - not actually defined anywhere. This prevents people from accidentally trying to copy a WvStream without defining one. |
|
plain internal constructor to just set up internal variables. Definition at line 463 of file include/wvstream.h. |
|
constructor to create a WvStream from an existing file descriptor. The file descriptor is closed automatically by the destructor. If this is undesirable, duplicate it first using dup(). |
|
|
|
copy constructor - not actually defined anywhere. This prevents people from accidentally trying to copy a WvStream without defining one. |
|
plain internal constructor to just set up internal variables. Definition at line 463 of file streams/wvstream.h. |
|
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. |
|
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 113 of file wvstream.cc. References callfunc, execute(), running_callback, userdata, and wvstream_execute_called. Referenced by callback(). |
|
The function that does the actual work of select(). |
|
The function that does the actual work of select(). Definition at line 586 of file wvstream.cc. References WvStream::SelectInfo::except, force, WvStream::SelectInfo::inherit_request, WvStream::SelectRequest::isexception, isok(), WvStream::SelectInfo::max_fd, WvStream::SelectInfo::msec_timeout, post_select(), pre_select(), WvStream::SelectInfo::read, WvStream::SelectRequest::readable, seterr(), WvStream::SelectInfo::wants, WvStream::SelectRequest::writable, and WvStream::SelectInfo::write. Referenced by select(). |
|
set an alarm, ie. select() will return true after this many ms. The alarm is cleared when callback() is called. |
|
set an alarm, ie. select() will return true after this many ms. The alarm is cleared when callback() is called. Definition at line 660 of file wvstream.cc. References alarm_time, and normalize(). Referenced by continue_select(). |
|
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(). |
|
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 679 of file wvstream.cc. References alarm_time, and normalize(). Referenced by callback(), WvStreamList::pre_select(), WvStreamClone::pre_select(), and pre_select(). |
|
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 391 of file streams/wvstream.h. References autoforward_callback(), and setcallback(). |
|
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 391 of file include/wvstream.h. References autoforward_callback(), and setcallback(). Referenced by main(). |
|
|
|
Definition at line 99 of file wvstream.cc. References read(), userdata, and write(). Referenced by autoforward(). |
|
if the stream has a callback function defined, call it now. otherwise call execute(). |
|
if the stream has a callback function defined, call it now. otherwise call execute(). Definition at line 135 of file wvstream.cc. References _callback(), alarm_remaining(), alarm_time, alarm_was_ticking, WvTask::isrunning(), personal_stack_size, WvTaskMan::run(), running_callback, WvTask::start(), WvTaskMan::start(), task, taskman, TRACE, and uses_continue_select. Referenced by WvStreamList::execute(), WvStreamClone::execute(), and main(). |
|
Close the stream if it is open; isok() becomes false from now on. Note!! If you override this function in a derived class, you must call it yourself from your destructor. WvStream::~WvStream() can only call WvStream::close() because of the way virtual functions work in C++. Reimplemented in WvSSLStream, WvModemBase, WvModem, WvSplitStream, WvSSLStream, WvStreamClone, WvTCPListener, WvUnixListener, WvTCPListener, WvUnixListener, WvModemBase, WvModem, WvSplitStream, and WvStreamClone. |
|
Close the stream if it is open; isok() becomes false from now on. Note!! If you override this function in a derived class, you must call it yourself from your destructor. WvStream::~WvStream() can only call WvStream::close() because of the way virtual functions work in C++. Reimplemented in WvSSLStream, WvModemBase, WvModem, WvSplitStream, WvSSLStream, WvStreamClone, WvTCPListener, WvUnixListener, WvTCPListener, WvUnixListener, WvModemBase, WvModem, WvSplitStream, and WvStreamClone. Definition at line 86 of file wvstream.cc. References flush(), getrfd(), getwfd(), and rwfd. Referenced by WvUnixListener::close(), WvTCPListener::close(), WvStreamClone::close(), WvSplitStream::close(), WvModem::close(), flush(), WvLockFile::lock(), WvFileWatcher::make_ok(), WvFile::open(), seterr(), terminate_continue_select(), WvFileWatcher::WvFileWatcher(), WvPipe::~WvPipe(), ~WvStream(), and WvUnixConn::~WvUnixConn(). |
|
|
|
Definition at line 712 of file wvstream.cc. References alarm(), alarm_was_ticking, running_callback, select(), task, taskman, uses_continue_select, WvTaskMan::whoami(), and WvTaskMan::yield(). Referenced by 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 161 of file streams/wvstream.h. References outbuf_delayed_flush. |
|
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 161 of file include/wvstream.h. References outbuf_delayed_flush. Referenced by bouncer(). |
|
drain the input buffer (read and discard data until select(0) returns false) |
|
drain the input buffer (read and discard data until select(0) returns false) Definition at line 449 of file wvstream.cc. References read(), and select(). Referenced by WvModemBase::hangup(), and WvModem::setup_modem(). |
|
Reimplemented in WvHTTPStream, WvStreamClone, WvHTTPStream, and WvStreamClone. |
|
Reimplemented in WvHTTPStream, WvStreamClone, WvHTTPStream, and WvStreamClone. Definition at line 277 of file wvstream.cc. References errnum, and errstring. Referenced by WvStreamClone::errstr(), WvConf::load_file(), and main(). |
|
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 in WvDailyEvent, WvProtoStream, WvStreamClone, WvStreamList, WvTimeStream, WvDailyEvent, WvProtoStream, WvStreamClone, WvStreamList, and WvTimeStream. |
|
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 in WvDailyEvent, WvProtoStream, WvStreamClone, WvStreamList, WvTimeStream, WvDailyEvent, WvProtoStream, WvStreamClone, WvStreamList, and WvTimeStream. Definition at line 217 of file wvstream.cc. References wvstream_execute_called. Referenced by _callback(), WvTimeStream::execute(), WvStreamList::execute(), WvStreamClone::execute(), and WvDailyEvent::execute(). |
|
flush the output buffer, if we can do it without delaying more than msec_timeout milliseconds at a time. (-1 means wait forever) |
|
flush the output buffer, if we can do it without delaying more than msec_timeout milliseconds at a time. (-1 means wait forever) Definition at line 457 of file wvstream.cc. References autoclose_time, close(), WvBuffer::get(), isok(), outbuf, select(), TRACE, WvBuffer::unget(), WvBuffer::used(), and uwrite(). Referenced by close(), flush_then_close(), WvStreamClone::post_select(), post_select(), and write(). |
|
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) |
|
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 497 of file wvstream.cc. References autoclose_time, flush(), outbuf, TRACE, and WvBuffer::used(). |
|
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().) |
|
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 644 of file wvstream.cc. References force, WvStream::SelectRequest::isexception, WvStream::SelectRequest::readable, and WvStream::SelectRequest::writable. 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 in WvHTTPStream, WvStreamClone, WvHTTPStream, and 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 in WvHTTPStream, WvStreamClone, WvHTTPStream, and WvStreamClone. Definition at line 271 of file wvstream.cc. References errnum. Referenced by WvStreamClone::geterr(), WvConf::load_file(), and WvHTTPStream::pre_select(). |
|
return the rfd _and_ the wfd... if they're the same. |
|
return the rfd _and_ the wfd... if they're the same. Definition at line 238 of file wvstream.cc. References getrfd(), and getwfd(). Referenced by WvUnixListener::accept(), WvTCPListener::accept(), WvTCPConn::do_connect(), WvUDPStream::enable_broadcasts(), WvTCPConn::localaddr(), WvTCPConn::low_delay(), WvTCPConn::nice_tcpopts(), WvTCPConn::post_select(), WvUDPStream::uread(), WvUDPStream::uwrite(), WvTCPConn::WvTCPConn(), WvTCPListener::WvTCPListener(), WvUDPStream::WvUDPStream(), WvUnixConn::WvUnixConn(), and WvUnixListener::WvUnixListener(). |
|
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 If wait_msec < 0, waits forever for a newline (bad idea!) If wait_msec=0, never waits. Otherwise, waits up to wait_msec milliseconds until a newline appears. This now uses the dynamic-sized WvBuffer. It is expected that there will be no NULL characters on the line. |
|
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 If wait_msec < 0, waits forever for a newline (bad idea!) If wait_msec=0, never waits. Otherwise, waits up to wait_msec milliseconds until a newline appears. This now uses the dynamic-sized WvBuffer. It is expected that there will be no NULL characters on the line. Definition at line 388 of file wvstream.cc. References WvBuffer::alloc(), continue_select(), WvBuffer::get(), inbuf, isok(), queuemin(), select(), WvBuffer::strchr(), WvBuffer::unalloc(), uread(), and WvBuffer::used(). Referenced by concallback(), WvProtoStream::execute(), WvResolver::findaddr(), WvIPRouteList::get_kernel(), WvConf::load_file(), WvLockFile::lock(), main(), mycallback(), WvInterfaceDict::update(), and WvHTTPStream::uread(). |
|
return the Unix file descriptor for reading from this stream Reimplemented in WvSplitStream, WvStreamClone, WvSplitStream, and WvStreamClone. |
|
return the Unix file descriptor for reading from this stream Reimplemented in WvSplitStream, WvStreamClone, WvSplitStream, and WvStreamClone. Definition at line 225 of file wvstream.cc. References rwfd. Referenced by close(), WvModem::close(), WvModemBase::get_real_speed(), getfd(), WvStreamClone::getrfd(), WvModem::getstatus(), WvModemBase::hangup(), isok(), WvFileWatcher::make_ok(), post_select(), WvFileWatcher::pre_select(), pre_select(), WvModem::setup_modem(), WvModem::speed(), uread(), and WvPipe::WvPipe(). |
|
return the Unix file descriptor for writing to this stream Reimplemented in WvSplitStream, WvStreamClone, WvSplitStream, and WvStreamClone. |
|
return the Unix file descriptor for writing to this stream Reimplemented in WvSplitStream, WvStreamClone, WvSplitStream, and WvStreamClone. Definition at line 232 of file wvstream.cc. References rwfd. Referenced by close(), getfd(), WvStreamClone::getwfd(), isok(), post_select(), pre_select(), uwrite(), and WvPipe::WvPipe(). |
|
|
|
Definition at line 42 of file wvstream.cc. References alarm_time, alarm_was_ticking, autoclose_time, errnum, force, WvStream::SelectRequest::isexception, max_outbuf_size, outbuf_delayed_flush, personal_stack_size, queue_min, read_requires_writable, WvStream::SelectRequest::readable, running_callback, task, userdata, uses_continue_select, WvStream::SelectRequest::writable, write_requires_readable, and wvstream_execute_called. Referenced by WvStream(). |
|
return true if the stream is actually usable right now Reimplemented in WvDailyEvent, WvHTTPStream, WvLog, WvStreamClone, WvStreamList, WvTCPConn, WvTimeStream, WvFileWatcher, WvHTTPStream, WvTCPConn, WvDailyEvent, WvLog, WvStreamClone, WvStreamList, WvTimeStream, and WvFileWatcher. |
|
|
Reimplemented in WvLog. Definition at line 430 of file streams/wvstream.h. References write(). |
|
Reimplemented in WvLog, and WvLog. Definition at line 428 of file streams/wvstream.h. References write(). |
|
Reimplemented in WvLog. Definition at line 430 of file include/wvstream.h. References write(). |
|
Reimplemented in WvLog, and WvLog. Definition at line 428 of file include/wvstream.h. References write(). 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. (DLC: 12/15/2000) Definition at line 102 of file streams/wvstream.h. References max_outbuf_size, and size. |
|
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. (DLC: 12/15/2000) Definition at line 102 of file include/wvstream.h. References max_outbuf_size, and size. |
|
A more convenient version of post_select() usable for overriding the 'want' value temporarily. Definition at line 280 of file streams/wvstream.h. References post_select(), and WvStream::SelectInfo::wants. |
|
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. (post_select() _only_ gets called if select() returned true for _some_ stream or another.) 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 in WvSSLStream, WvDailyEvent, WvSSLStream, WvStreamClone, WvStreamList, WvTCPConn, WvTimeStream, WvTCPConn, WvDailyEvent, WvStreamClone, WvStreamList, and WvTimeStream. |
|
A more convenient version of post_select() usable for overriding the 'want' value temporarily. Definition at line 280 of file include/wvstream.h. References post_select(), and WvStream::SelectInfo::wants. |
|
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. (post_select() _only_ gets called if select() returned true for _some_ stream or another.) 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 in WvSSLStream, WvDailyEvent, WvSSLStream, WvStreamClone, WvStreamList, WvTCPConn, WvTimeStream, WvTCPConn, WvDailyEvent, WvStreamClone, WvStreamList, and WvTimeStream. Definition at line 553 of file wvstream.cc. References autoclose_time, WvStream::SelectInfo::except, flush(), getrfd(), getwfd(), isok(), outbuf, WvStream::SelectInfo::read, read_requires_writable, WvStream::SelectRequest::readable, select(), WvBuffer::used(), WvStream::SelectInfo::wants, WvStream::SelectRequest::writable, WvStream::SelectInfo::write, and write_requires_readable. Referenced by _select(), WvTCPConn::post_select(), WvStreamList::post_select(), WvStreamClone::post_select(), and post_select(). |
|
A more convenient version of pre_select() usable for overriding the 'want' value temporarily. Definition at line 252 of file streams/wvstream.h. References pre_select(), and WvStream::SelectInfo::wants. |
|
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 in WvSSLStream, WvDailyEvent, WvHTTPStream, WvSSLStream, WvStreamClone, WvStreamList, WvTCPConn, WvTimeStream, WvFileWatcher, WvHTTPStream, WvTCPConn, WvDailyEvent, WvStreamClone, WvStreamList, WvTimeStream, and WvFileWatcher. |
|
A more convenient version of pre_select() usable for overriding the 'want' value temporarily. Definition at line 252 of file include/wvstream.h. References pre_select(), and WvStream::SelectInfo::wants. |
|
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 in WvSSLStream, WvDailyEvent, WvHTTPStream, WvSSLStream, WvStreamClone, WvStreamList, WvTCPConn, WvTimeStream, WvFileWatcher, WvHTTPStream, WvTCPConn, WvDailyEvent, WvStreamClone, WvStreamList, WvTimeStream, and WvFileWatcher. Definition at line 514 of file wvstream.cc. References alarm_remaining(), autoclose_time, WvStream::SelectInfo::except, getrfd(), getwfd(), inbuf, WvStream::SelectRequest::isexception, WvStream::SelectInfo::max_fd, WvStream::SelectInfo::msec_timeout, outbuf, queue_min, WvStream::SelectInfo::read, WvStream::SelectRequest::readable, WvBuffer::used(), WvStream::SelectInfo::wants, WvStream::SelectRequest::writable, and WvStream::SelectInfo::write. Referenced by _select(), WvTCPConn::pre_select(), WvStreamList::pre_select(), WvStreamClone::pre_select(), pre_select(), and WvResolver::pre_select(). |
|
preformat and print a string. Definition at line 426 of file streams/wvstream.h. References write(). |
|
Definition at line 420 of file streams/wvstream.h. References write(). |
|
preformat and print a string. Definition at line 426 of file include/wvstream.h. References write(). |
|
Definition at line 420 of file include/wvstream.h. References write(). Referenced by concallback(), WvLogBuffer::dump(), WvHConf::dump(), WvConfigSection::dump(), WvLockFile::lock(), main(), mycallback(), namelookup(), WvLog::operator()(), WvLog::perror(), WvHTTPStream::pre_select(), and WvConf::save(). |
|
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. queuemin() mainly affects what happens when you do a read(), not so much what happens when you do a select(). If you set queuemin != 0, you might still select true for read, but read() might return 0 bytes since it's holding back data until enough bytes are ready in inbuf. WARNING: getline() sets queuemin to 0 automatically! Definition at line 147 of file streams/wvstream.h. References queue_min. |
|
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. queuemin() mainly affects what happens when you do a read(), not so much what happens when you do a select(). If you set queuemin != 0, you might still select true for read, but read() might return 0 bytes since it's holding back data until enough bytes are ready in inbuf. WARNING: getline() sets queuemin to 0 automatically! Definition at line 147 of file include/wvstream.h. References queue_min. Referenced by getline(), WvRSAStream::WvRSAStream(), and WvRSAStream::~WvRSAStream(). |
|
read a data block on the stream. Returns the actual amount read. |
|
read a data block on the stream. Returns the actual amount read. Definition at line 289 of file wvstream.cc. References WvBuffer::alloc(), WvBuffer::get(), inbuf, queue_min, TRACE, WvBuffer::unalloc(), uread(), and WvBuffer::used(). Referenced by autoforward_callback(), bouncer(), drain(), WvStreamClone::uread(), and WvHTTPStream::uread(). |
|
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. Definition at line 324 of file streams/wvstream.h. References _select(). |
|
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(). Definition at line 308 of file streams/wvstream.h. References _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. Definition at line 324 of file include/wvstream.h. References _select(). |
|
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(). Definition at line 308 of file include/wvstream.h. References _select(). Referenced by continue_select(), drain(), WvResolver::findaddr(), flush(), getline(), WvModemBase::hangup(), main(), WvStreamClone::post_select(), post_select(), WvHTTPStream::pre_select(), 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 383 of file streams/wvstream.h. |
|
define the callback function for this stream, called whenever the callback() member is run, and passed the 'userdata' pointer. Definition at line 383 of file include/wvstream.h. References callfunc, and userdata. Referenced by WvUnixListener::accept_callback(), WvTCPListener::accept_callback(), WvUnixListener::auto_accept(), WvTCPListener::auto_accept(), autoforward(), and main(). |
|
|
|
set the errnum variable and close the stream -- we have an error. |
|
Definition at line 260 of file wvstream.cc. |
|
set the errnum variable and close the stream -- we have an error. Definition at line 252 of file wvstream.cc. References close(), and errnum. Referenced by _select(), WvTCPConn::check_resolver(), WvTCPConn::do_connect(), WvFile::open(), WvTCPConn::post_select(), WvSSLStream::post_select(), WvHTTPStream::pre_select(), WvModem::setup_modem(), uread(), WvSSLStream::uread(), WvHTTPStream::uread(), WvUDPStream::uwrite(), uwrite(), WvSSLStream::uwrite(), WvSSLStream::WvSSLStream(), WvTCPConn::WvTCPConn(), WvTCPListener::WvTCPListener(), WvUDPStream::WvUDPStream(), WvUnixConn::WvUnixConn(), and WvUnixListener::WvUnixListener(). |
|
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 in WvStreamClone, WvTCPConn, WvTCPListener, WvUDPStream, WvUnixConn, WvUnixListener, WvTCPConn, WvTCPListener, WvUDPStream, WvUnixConn, WvUnixListener, and WvStreamClone. |
|
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 in WvStreamClone, WvTCPConn, WvTCPListener, WvUDPStream, WvUnixConn, WvUnixListener, WvTCPConn, WvTCPListener, WvUDPStream, WvUnixConn, WvUnixListener, and WvStreamClone. Definition at line 749 of file wvstream.cc. Referenced by WvStreamClone::src(). |
|
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(). |
|
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 736 of file wvstream.cc. References close(), WvTask::isrunning(), WvTask::recycle(), WvTaskMan::run(), task, and taskman. |
|
Undo a previous force_select() - ie. un-forces the options which are 'true', and leaves the false ones alone. |
|
Undo a previous force_select() - ie. un-forces the options which are 'true', and leaves the false ones alone. Definition at line 652 of file wvstream.cc. References force, WvStream::SelectRequest::isexception, WvStream::SelectRequest::readable, and WvStream::SelectRequest::writable. Referenced by WvSSLStream::post_select(). |
|
unbuffered I/O functions; these ignore the buffer, which is handled by read(). Don't call these functions unless you have a _really_ good reason. Reimplemented in WvXORStream, WvBlowfishStream, WvRSAStream, WvSSLStream, WvXORStream, WvBlowfishStream, WvRSAStream, WvHTTPStream, WvSSLStream, WvStreamClone, WvTCPListener, WvUDPStream, WvUnixListener, WvFileWatcher, WvHTTPStream, WvTCPListener, WvUDPStream, WvUnixListener, WvStreamClone, and WvFileWatcher. |
|
unbuffered I/O functions; these ignore the buffer, which is handled by read(). Don't call these functions unless you have a _really_ good reason. Reimplemented in WvXORStream, WvBlowfishStream, WvRSAStream, WvSSLStream, WvXORStream, WvBlowfishStream, WvRSAStream, WvHTTPStream, WvSSLStream, WvStreamClone, WvTCPListener, WvUDPStream, WvUnixListener, WvFileWatcher, WvHTTPStream, WvTCPListener, WvUDPStream, WvUnixListener, WvStreamClone, and WvFileWatcher. Definition at line 324 of file wvstream.cc. References getrfd(), isok(), and seterr(). Referenced by getline(), read(), and WvFileWatcher::uread(). |
|
unbuffered I/O functions; these ignore the buffer, which is handled by write(). Don't call these functions unless you have a _really_ good reason. Reimplemented in WvXORStream, WvBlowfishStream, WvRSAStream, WvSSLStream, WvXORStream, WvBlowfishStream, WvRSAStream, WvLog, WvProtoStream, WvSSLStream, WvStreamClone, WvTCPListener, WvUDPStream, WvUnixListener, WvFileWatcher, WvTCPListener, WvUDPStream, WvUnixListener, WvLog, WvProtoStream, WvStreamClone, and WvFileWatcher. |
|
unbuffered I/O functions; these ignore the buffer, which is handled by write(). Don't call these functions unless you have a _really_ good reason. Reimplemented in WvXORStream, WvBlowfishStream, WvRSAStream, WvSSLStream, WvXORStream, WvBlowfishStream, WvRSAStream, WvLog, WvProtoStream, WvSSLStream, WvStreamClone, WvTCPListener, WvUDPStream, WvUnixListener, WvFileWatcher, WvTCPListener, WvUDPStream, WvUnixListener, WvLog, WvProtoStream, WvStreamClone, and WvFileWatcher. Definition at line 366 of file wvstream.cc. References getwfd(), isok(), and seterr(). Referenced by WvLogConsole::_mid_line(), flush(), WvFileWatcher::uwrite(), WvStreamClone::uwrite(), and write(). |
|
print a preformatted WvString to the stream. see the simple version of write() way up above. Definition at line 418 of file streams/wvstream.h. References write(). |
|
write a data block on the stream. Returns the actual amount written. |
|
print a preformatted WvString to the stream. see the simple version of write() way up above. Definition at line 418 of file include/wvstream.h. References write(). |
|
write a data block on the stream. Returns the actual amount written. Definition at line 343 of file wvstream.cc. References flush(), isok(), max_outbuf_size, outbuf, outbuf_delayed_flush, WvBuffer::put(), WvBuffer::used(), and uwrite(). Referenced by autoforward_callback(), bouncer(), WvModemBase::hangup(), operator()(), WvLog::operator()(), print(), WvModem::setup_modem(), WvProtoStream::uwrite(), and write(). |
|
Definition at line 454 of file streams/wvstream.h. |
|
Definition at line 454 of file include/wvstream.h. Referenced by alarm(), alarm_remaining(), callback(), and init(). |
|
Definition at line 451 of file streams/wvstream.h. Referenced by callback(), continue_select(), and init(). |
|
Definition at line 453 of file streams/wvstream.h. Referenced by flush(), flush_then_close(), init(), WvStreamClone::post_select(), post_select(), WvStreamClone::pre_select(), and pre_select(). |
|
Definition at line 445 of file streams/wvstream.h. Referenced by _callback(), and setcallback(). |
|
Definition at line 447 of file streams/wvstream.h. Referenced by errstr(), WvStreamClone::geterr(), geterr(), init(), seterr(), WvPipe::setup(), WvFileWatcher::WvFileWatcher(), WvLoopback::WvLoopback(), and WvModem::WvModem(). |
|
Definition at line 448 of file streams/wvstream.h. |
|
'force' is the list of default SelectRequest values when you use the variant of select() that doesn't override them. Definition at line 199 of file streams/wvstream.h. Referenced by _select(), force_select(), init(), WvStreamList::post_select(), WvStreamClone::post_select(), WvStreamList::pre_select(), WvStreamClone::pre_select(), and undo_force_select(). |
|
Definition at line 449 of file streams/wvstream.h. Referenced by getline(), WvStreamClone::pre_select(), pre_select(), read(), and WvRSAStream::uread(). |
|
Definition at line 450 of file streams/wvstream.h. Referenced by init(), outbuf_limit(), and write(). |
|
Definition at line 449 of file streams/wvstream.h. Referenced by flush(), flush_then_close(), WvStreamClone::post_select(), post_select(), WvStreamClone::pre_select(), pre_select(), and write(). |
|
Definition at line 451 of file streams/wvstream.h. Referenced by delay_output(), init(), and write(). |
|
Definition at line 363 of file streams/wvstream.h. |
|
Definition at line 452 of file streams/wvstream.h. Referenced by init(), WvStreamClone::pre_select(), pre_select(), queuemin(), and read(). |
|
If this is set, select() doesn't return true for read unless the given stream also returns true for write. Definition at line 205 of file streams/wvstream.h. |
|
If this is set, select() doesn't return true for read unless the given stream also returns true for write. Definition at line 205 of file include/wvstream.h. Referenced by init(), WvStreamClone::post_select(), and post_select(). |
|
Definition at line 455 of file streams/wvstream.h. Referenced by _callback(), callback(), continue_select(), init(), and ~WvStream(). |
|
Definition at line 447 of file streams/wvstream.h. Referenced by close(), WvTCPConn::do_connect(), getrfd(), getwfd(), WvFile::open(), WvPipe::setup(), WvStream(), WvTCPListener::WvTCPListener(), WvUDPStream::WvUDPStream(), WvUnixConn::WvUnixConn(), and WvUnixListener::WvUnixListener(). |
|
Definition at line 458 of file streams/wvstream.h. |
|
Definition at line 458 of file include/wvstream.h. Referenced by callback(), continue_select(), init(), terminate_continue_select(), and ~WvStream(). |
|
Definition at line 457 of file streams/wvstream.h. |
|
Definition at line 26 of file wvstream.cc. Referenced by callback(), continue_select(), terminate_continue_select(), and ~WvStream(). |
|
Definition at line 446 of file streams/wvstream.h. |
|
Definition at line 446 of file include/wvstream.h. Referenced by _callback(), WvUnixListener::accept_callback(), WvTCPListener::accept_callback(), WvUnixListener::auto_accept(), WvTCPListener::auto_accept(), autoforward_callback(), init(), and setcallback(). |
|
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 362 of file streams/wvstream.h. Referenced by callback(), continue_select(), and init(). |
|
If this is set, select() doesn't return true for write unless the given stream also returns true for read. Definition at line 211 of file streams/wvstream.h. |
|
If this is set, select() doesn't return true for write unless the given stream also returns true for read. Definition at line 211 of file include/wvstream.h. Referenced by init(), WvStreamClone::post_select(), and post_select(). |
|
Definition at line 435 of file streams/wvstream.h. |