Socket.createSource

Creates a GSource that can be attached to a GMainContext to monitor for the availibility of the specified condition on the socket. The callback on the source is of the GSocketSourceFunc type. It is meaningless to specify G_IO_ERR or G_IO_HUP in condition; these conditions will always be reported output if they are true. cancellable if not NULL 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 g_cancellable_is_cancelled(). If socket has a timeout set, and it is reached before condition occurs, the source will then trigger anyway, reporting G_IO_IN or G_IO_OUT depending on condition. However, socket will have been marked as having had a timeout, and so the next GSocket I/O method you call will then fail with a G_IO_ERROR_TIMED_OUT. Since 2.22

Parameters

condition GIOCondition

a GIOCondition mask to monitor

cancellable Cancellable

a GCancellable or NULL. [allow-none]

Return Value

Type: Source

a newly allocated GSource, free with g_source_unref(). [transfer full]

Meta