Poco::Net

class PollSet

File Information

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, empty, has, poll, remove, update

Types Aliases

SocketModeMap

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

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.

empty

bool empty() const;

Returns true if no socket is registered for polling.

has

bool has(
    const Socket & socket
) const;

Returns true if socket is registered for polling.

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.

Securely control IoT edge devices from anywhere   Connect a Device