Event Loop - File Interface

File Interface

Under Unix, the "everything is a file" paradigm naturally leads to a file-based event loop. Reading from and writing to files, inter-process communication, network communication and device control are all achieved using file I/O, with the target identified by a file descriptor. The select and poll system calls allow a set of file descriptors to be monitored for a change of state, e.g. when data becomes available to be read.

For example, consider a program that reads from a continuously updated file and displays its contents in the X Window System, which communicates with clients over a socket (either Unix domain or Berkeley):

main: file_fd = open ("logfile") x_fd = open_display_construct_interface_while_changed_fds = select ({file_fd, x_fd}): if file_fd_in_changed_fds: data = read_from (file_fd) append_to_display (data) send_repaint_message_if_x_fd in changed_fds: process_x_messages

Read more about this topic:  Event Loop

Other articles related to "file interface, file, files, interface":

Event Loop - File Interface - Handling Signals
... One of the few things in Unix that do not conform to the file interface are asynchronous events (signals) ... after the select call if it is set, handle the signal in the same manner as with events on file descriptors ... An alternative, more portable solution, is to convert asynchronous events to file-based events using the self-pipe trick, where "a signal handler writes a byte ...
XBMC - History - Releases
... size, custom Tags parsing and display for wma, m4a, mp4 and aac (mpeg-4 audio) audio-files International-language fonts for subtitles via TTF-fonts Audio CD Ripper ... gapless playback and ReplayGain support RAR/ZIP archive parsing Karaoke CDG-file display Xored Trainer Engine (gaming-cheats) (not ported from Xbox to other ... Jaunty Jackalope) 9.11 24 December 2009 Camelot Revamped user interface via the new default skin “Confluence“ DirectX support by default for the Windows platform A complete reorganization ...

Famous quotes containing the word file:

    A common and natural result of an undue respect for law is, that you may see a file of soldiers, colonel, captain, corporal, privates, powder-monkeys, and all, marching in admirable order over hill and dale to the wars, against their wills, ay, against their common sense and consciences, which makes it very steep marching indeed, and produces a palpitation of the heart.
    Henry David Thoreau (1817–1862)