Galaxy Communicator Documentation:

Main loop example

License / Documentation home / Help and feedback

In this example, we show how the Communicator main loop works, and how to recreate Communicator server functionality in other main loops.

This example can be found in the distribution in contrib/MITRE/examples/simple_mainloop.

Source files

simple_mainloop.c: provides a crude main loop for illustration purposes, which allows the user to set callbacks on file descriptors and on "timers" (actually, loop iterations, but it serves the purpose). This file defines the functions SM_AddTimerCallback, SM_RemoveTimerCallback, SM_AddFDCallback, SM_RemoveFDCallback, and SM_Mainloop ("SM" stands for "simple mainloop").

simple_mainloop_elr.c: uses this crude mainloop to run a Communicator-compliant server.

mainloop_double.c: the standard double server from the double example, using simple_mainloop_elr.c.

basic_double.c: a double server with an explicit main loop (essentially a copy of the one in the GalaxyCommunicator core library), to contrast with the other servers in this example.

Running the example

All configurations in this example can be accessed by invoking the process monitor, as follows.

% cd <root_of_GC>
% ./contrib/MITRE/tools/bin/process_monitor contrib/MITRE/examples/simple_mainloop/simple_mainloop.config


C:\> set GC_HOME=<root_of_GC>
C:\> python %GC_HOME%\
contrib\MITRE\tools\src\process_monitor\ %GC_HOME%\contrib\MITRE\examples\simple_mainloop\simple_mainloop.config
In addition, on Unix, we generate the following scripts.

mainloop_double.csh: runs the mainloop_double server and the Hub, using the double program file from the double example.

mainloop_audio.csh: runs the mainloop_testaudio_send and mainloop_testaudio_receive servers and the Hub, using the audio program file from the audio example.

basic_double.csh: runs the basic double server and the Hub, using the double program file from the double example.


On Unix, typing "make" in this directory will create the servers, MIT-style Makefiles, and scripts.

The C version of this server contains a MSVC workspace for Windows, which is also included in the toplevel MSVC workspace for the Galaxy Communicator distribution.


See the documentation on server structure and alternative main loops.

License / Documentation home / Help and feedback
Last updated August 8, 2002