The glib.iochannel.IOChannel data type aims to provide a portable method for
using file descriptors, pipes, and sockets, and integrating them
into the main event loop (see glib.main_context.MainContext). Currently,
full support is available on UNIX platforms; support for Windows
is only partially complete.
To add a glib.iochannel.IOChannel to the main event loop, use func@GLib.io_add_watch or
func@GLib.io_add_watch_full. Here you specify which events you are
interested in on the glib.iochannel.IOChannel, and provide a function to be called
whenever these events occur.
The glib.iochannel.IOChannel data type aims to provide a portable method for using file descriptors, pipes, and sockets, and integrating them into the main event loop (see glib.main_context.MainContext). Currently, full support is available on UNIX platforms; support for Windows is only partially complete.
To create a new glib.iochannel.IOChannel on UNIX systems use glib.iochannel.IOChannel.unixNew. This works for plain file descriptors, pipes and sockets. Alternatively, a channel can be created for a file in a system independent manner using glib.iochannel.IOChannel.newFile.
Once a glib.iochannel.IOChannel has been created, it can be used in a generic manner with the functions glib.iochannel.IOChannel.readChars, glib.iochannel.IOChannel.writeChars, glib.iochannel.IOChannel.seekPosition, and glib.iochannel.IOChannel.shutdown.
To add a glib.iochannel.IOChannel to the main event loop, use func@GLib.io_add_watch or func@GLib.io_add_watch_full. Here you specify which events you are interested in on the glib.iochannel.IOChannel, and provide a function to be called whenever these events occur.
glib.iochannel.IOChannel instances are created with an initial reference count of 1. glib.iochannel.IOChannel.ref_ and glib.iochannel.IOChannel.unref can be used to increment or decrement the reference count respectively. When the reference count falls to 0, the glib.iochannel.IOChannel is freed. (Though it isn’t closed automatically, unless it was created using glib.iochannel.IOChannel.newFile.) Using func@GLib.io_add_watch or func@GLib.io_add_watch_full increments a channel’s reference count.
The new functions glib.iochannel.IOChannel.readChars, glib.iochannel.IOChannel.readLine, glib.iochannel.IOChannel.readLineString, glib.iochannel.IOChannel.readToEnd, glib.iochannel.IOChannel.writeChars, glib.iochannel.IOChannel.seekPosition, and glib.iochannel.IOChannel.flush should not be mixed with the deprecated functions glib.iochannel.IOChannel.read, glib.iochannel.IOChannel.write, and glib.iochannel.IOChannel.seek on the same channel.