FBB::Selector

FBB::Selector

libbobcat1-dev_2.02.03-x.tar.gz

2005-2009


FBB::Selector(3bobcat)

FBB::Selector(3bobcat)

libbobcat1-dev_2.02.03-x.tar.gz Timed Delays, Multiple File I/O

2005-2009

NAME

FBB::Selector - Timed delays, Alarms and Multiple File I/O.

SYNOPSIS

#include <bobcat/selector>
Linking option: -lbobcat

DESCRIPTION

FBB::Selector objects are wrappers around the select()(2) system calls and allow timed delays, alarm functionality and/or multiple file I/O. It requires the use of file descriptors, which are not an official part of C++. However, most operating systems offer file descriptors. Sockets are well-known file descriptors.

NAMESPACE

FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.

INHERITS FROM

-

CONSTRUCTORS

The copy constructor is available.

MEMBER FUNCTIONS

EXAMPLE


#include <string>
#include <iostream>

#include <bobcat/selector>
#include <bobcat/errno>

using namespace std;
using namespace FBB;

int main(int argc, char **argv, char **envp)
{
    Selector selector;

    selector.setAlarm(5);               // every 5 secs: alarm fires
    selector.addReadFd(STDIN_FILENO);   // look also at cin

    try
    {
        while (true)
        {
            if (!selector.wait())           // 0: alarm fires
                cout << "Are you still there?" << endl;                
            else
            {
                string s;
                if (!getline(cin, s) || !s.length())
                    return 0;
                cout << "Thank you for: " << s << endl;
            }
        }
    }
    catch (Errno const &e)
    {
        cout << e.what() << endl;
    }
    return 0;
}
    

FILES

bobcat/selector - defines the class interface

SEE ALSO

bobcat(7), select(2)

BUGS

None Reported.

DISTRIBUTION FILES

BOBCAT

Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.

COPYRIGHT

This is free software, distributed under the terms of the GNU General Public License (GPL).

AUTHOR

Frank B. Brokken (f.b.brokken@rug.nl).