Poco::Net

class PollSet

Library: Net
Package: Sockets
Header: Poco/Net/PollSet.h

Description

A set of sockets that can be efficiently polled as a whole.

If supported, PollSet is implemented using epoll (Linux) or poll (BSD) APIs. A fallback implementation using select() is also provided.

Member Summary

Member Functions: add, clear, poll, remove, update

Types

SocketModeMap

typedef std::map < Poco::Net::Socket, int > SocketModeMap;

Enumerations

Mode

POLL_READ = 0x01

POLL_WRITE = 0x02

POLL_ERROR = 0x04

Constructors

PollSet

PollSet();

Creates an empty PollSet.

Destructor

~PollSet

~PollSet();

Destroys the PollSet.

Member Functions

add

void add(
    const Poco::Net::Socket & socket,
    int mode
);

Adds the given socket to the set, for polling with the given mode, which can be an OR'd combination of POLL_READ, POLL_WRITE and POLL_ERROR.

clear

void clear();

Removes all sockets from the PollSet.

poll

SocketModeMap poll(
    const Poco::Timespan & timeout
);

Waits until the state of at least one of the PollSet's sockets changes accordingly to its mode, or the timeout expires. Returns a PollMap containing the sockets that have had their state changed.

remove

void remove(
    const Poco::Net::Socket & socket
);

Removes the given socket from the set.

update

void update(
    const Poco::Net::Socket & socket,
    int mode
);

Updates the mode of the given socket.