Class IOChannel

java.lang.Object
All Implemented Interfaces:
Proxy

@Generated("io.github.jwharm.JavaGI") public class IOChannel extends ProxyInstance
The GIOChannel 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.MainContext). Currently, full support is available on UNIX platforms; support for Windows is only partially complete.

To create a new GIOChannel on UNIX systems use unixNew(int). This works for plain file descriptors, pipes and sockets. Alternatively, a channel can be created for a file in a system independent manner using file(java.lang.String, java.lang.String).

Once a GIOChannel has been created, it can be used in a generic manner with the functions readChars(io.github.jwharm.javagi.base.Out<byte[]>, io.github.jwharm.javagi.base.Out<java.lang.Long>), writeChars(byte[], long, io.github.jwharm.javagi.base.Out<java.lang.Long>), seekPosition(long, org.gnome.glib.SeekType), and shutdown(boolean).

To add a GIOChannel to the main event loop, use GLib.ioAddWatch(org.gnome.glib.IOChannel, int, java.util.Set<org.gnome.glib.IOCondition>, org.gnome.glib.IOFunc) or GLib#ioAddWatchFull. Here you specify which events you are interested in on the GIOChannel, and provide a function to be called whenever these events occur.

GIOChannel instances are created with an initial reference count of 1. ref() and unref() can be used to increment or decrement the reference count respectively. When the reference count falls to 0, the GIOChannel is freed. (Though it isn’t closed automatically, unless it was created using file(java.lang.String, java.lang.String).) Using GLib.ioAddWatch(org.gnome.glib.IOChannel, int, java.util.Set<org.gnome.glib.IOCondition>, org.gnome.glib.IOFunc) or GLib#ioAddWatchFull increments a channel’s reference count.

The new functions readChars(io.github.jwharm.javagi.base.Out<byte[]>, io.github.jwharm.javagi.base.Out<java.lang.Long>), readLine(io.github.jwharm.javagi.base.Out<java.lang.String>, io.github.jwharm.javagi.base.Out<java.lang.Long>, io.github.jwharm.javagi.base.Out<java.lang.Long>), readLineString(org.gnome.glib.GString, java.lang.foreign.MemorySegment), readToEnd(io.github.jwharm.javagi.base.Out<byte[]>), writeChars(byte[], long, io.github.jwharm.javagi.base.Out<java.lang.Long>), seekPosition(long, org.gnome.glib.SeekType), and flush() should not be mixed with the deprecated functions read(java.lang.String, long, java.lang.foreign.MemorySegment), write(java.lang.String, long, java.lang.foreign.MemorySegment), and seek(long, org.gnome.glib.SeekType) on the same channel.