Let's look at a few streams that are only slightly more complicated than WvStream itself: WvFile, WvFileWatcher, and WvPipe.
WvFile is the simplest WvStream-derivative around. All it does is open a Unix file for you given a filename, so you don't have to supply the fd yourself.
/* * A WvFile example. * * Some text about this example... */ #include <wvfile.h> int main() { WvFile infile("/etc/passwd", O_RDONLY); char *s; while (infile.isok() && (s = infile.blocking_getline(-1)) != NULL) wvcon->print("%s\n", s); }
Need we say more?
Oh, since Unix devices are just files, you can use them with WvFile just as easily. For example, if your modem is /dev/ttyS2, you can connect to it by creating a WvFile that refers to /dev/ttyS2. Of course, the WvModem class is probably more useful for that particular job.