WvStreams
wvstreamex6.cc
1/*
2 * A WvStream example
3 *
4 * Some text about this example...
5 */
6
7#include <wvstream.h>
8
9void mycallback(WvStream &s, void *userdata)
10{
11 WvStream *outstream = (WvStream *)userdata;
12
13 char *str = s.getline();
14 if (str)
15 outstream->print("You said: %s\n", str);
16}
17
18int main()
19{
20 wvcon->setcallback(mycallback, wvcon);
21
22 while (wvcon->isok())
23 {
24 if (wvcon->select(-1))
25 wvcon->callback();
26 }
27}
Unified support for streams, that is, sequences of bytes that may or may not be ready for read/write ...
virtual bool isok() const
return true if the stream is actually usable right now
Definition wvstream.cc:445
void setcallback(IWvStreamCallback _callfunc)
define the callback function for this stream, called whenever the callback() member is run,...
Definition wvstream.cc:1129
bool select(time_t msec_timeout)
Return true if any of the requested features are true on the stream.
char * getline(time_t wait_msec=0, 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 th...
virtual void callback()
if the stream has a callback function defined, call it now.
Definition wvstream.cc:401