glibmm  2.64.4
Public Member Functions | List of all members
Gio::SignalSocket Class Reference

#include <giomm/socketsource.h>

Public Member Functions

sigc::connection connect (const sigc::slot< bool, Glib::IOCondition >& slot, const Glib::RefPtr< Socket >& socket, Glib::IOCondition condition, const Glib::RefPtr< Cancellable >& cancellable=Glib::RefPtr< Cancellable >(), int priority=Glib::PRIORITY_DEFAULT)
 Connects an I/O handler that watches a socket. More...
 

Detailed Description

Since glibmm 2.42:

Member Function Documentation

◆ connect()

sigc::connection Gio::SignalSocket::connect ( const sigc::slot< bool, Glib::IOCondition >&  slot,
const Glib::RefPtr< Socket >&  socket,
Glib::IOCondition  condition,
const Glib::RefPtr< Cancellable >&  cancellable = Glib::RefPtrCancellable >(),
int  priority = Glib::PRIORITY_DEFAULT 
)

Connects an I/O handler that watches a socket.

bool io_handler(Glib::IOCondition io_condition) { ... }

is equivalent to:

bool io_handler(Glib::IOCondition io_condition) { ... }
const auto socket_source = Gio::SocketSource::create(socket, Glib::IO_IN | Glib::IO_OUT);
socket_source->connect(sigc::ptr_fun(&io_handler));
socket_source->attach(Glib::MainContext::get_default());

This method is not thread-safe. You should call it, or manipulate the returned sigc::connection object, only from the thread where the SignalSocket object's MainContext runs.

Since glibmm 2.42:
Parameters
slotA slot to call when polling socket results in an event that matches condition. The event will be passed as a parameter to slot. If io_handler() returns false the handler is disconnected.
socketThe Socket object to watch.
conditionThe conditions to watch for.
cancellableA Cancellable object which can be used to cancel the source, which will cause the source to trigger, reporting the current condition (which is likely 0 unless cancellation happened at the same time as a condition change). You can check for this in the callback using Cancellable::is_cancelled().
priorityThe priority of the new event source.
Returns
A connection handle, which can be used to disconnect the handler.
Glib::Source::create
static Glib::RefPtr< Source > create()
sigc::ptr_fun
pointer_functor0< T_return > ptr_fun(T_return(*_A_func)())
Glib::MainContext::get_default
static Glib::RefPtr< MainContext > get_default()
Returns the global default main context.
Glib::IO_IN
@ IO_IN
A bitwise combination representing an I/O condition to watch for on an event source.
Definition: iochannel.h:238
Gio::SignalSocket::connect
sigc::connection connect(const sigc::slot< bool, Glib::IOCondition > &slot, const Glib::RefPtr< Socket > &socket, Glib::IOCondition condition, const Glib::RefPtr< Cancellable > &cancellable=Glib::RefPtr< Cancellable >(), int priority=Glib::PRIORITY_DEFAULT)
Connects an I/O handler that watches a socket.
Glib::IO_OUT
@ IO_OUT
Data can be written (without blocking).
Definition: iochannel.h:239
Glib::IOCondition
IOCondition
A bitwise combination representing a condition to watch for on an event source.
Definition: iochannel.h:237
Gio::signal_socket
SignalSocket signal_socket(const Glib::RefPtr< Glib::MainContext > &context=Glib::RefPtr< Glib::MainContext >())
Convenience socket signal.