IO Channels

G-Golf Glib IO Channels low level API.
IO Channels — portable support for using files, pipes and sockets

Procedures

g-io-channel-unix-new
g-io-channel-ref
g-io-channel-unref
g-io-create-watch

Types and Values

%g-io-condition

Description

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. Currently, full support is available on UNIX platforms, support for Windows is only partially complete.

Please read the IO Channels section from the Glib reference manual for a complete description.

Procedures

Note: in this section, the fd, channel and condition arguments are [must be] respectively an integer (a ‘valid’ file descriptor), a pointer to a GIOChannel and a list of one or more %g-io-condition flags.

Procedure: g-io-channel-unix-new fd

Returns a pointer.

Creates and returns a pointer to a new GIOChannel for fd (file descriptor). On UNIX systems this works for plain files, pipes, and sockets.

The newly created GIOChannel has a reference count of 1.

The default encoding for GIOChannel is UTF-8. If your application is reading output from a command using via pipe, you may need to set the encoding to the encoding of the current locale (FIXME - still missing a binding to g_io_channel_set_encoding).

Procedure: g-io-channel-ref channel

Returns channel.

Increments the channel reference count.

Procedure: g-io-channel-unref channel

Returns nothing.

Decrements the channel reference count.

Procedure: g-io-create-watch channel condition

Returns a pointer.

Creates and returns a pointer to a GSource that’s dispatched when condition is met for the given channel. For example, if condition is '(in), the source will be dispatched when there’s data available for reading.

Types and Values

Instance Variable of <gi-flag>: %g-io-condition

An instance of <gi-flag>, who’s members are the scheme representation of the GIOCondition flags:

g-name: GIOCondition
name: gio-condition
enum-set:

in

There is data to read.

out

Data can be written (without blocking).

pri

There is urgent data to read.

err

Error condition.

hup

Hung up (the connection has been broken, usually for pipes and sockets).

nval

Invalid request. The file descriptor is not open.