Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Examples  

Simple Unix Events (SUE) Library.

vers.0.1.1

Visit the official site at http://www.croco.net/software/sue

Introduction

Simple Unix Events (SUE) Library is a small and light-weight set of C++ classes which lets you easily create an event-driven application with C++ under Unix.

There are three types of events SUE can let you handle:

There is a specific support for client and server TCP sessions as well. This makes the library specially useful in implementing multiclient TCP servers which run as a single process handling all the clients without forking off any children.

Getting Started

First of all, you'll need one (and, likely, only one) object of the SUEEventSelector class. This object will be the heart of your application. In fact, you will always need an access to the object so you can consider making it a global variable. Another (and better) way is to create the object once and then pass its address to all your subsystems so that they can access it. Personally I prefer never never never ever use global variables, just as a matter of style.

SUEEventSelector provides the Go() method which will be the main loop of your application.

In order to handle some events, you'll need the following classes:

These classes are bases for your very own handlers; to make a handler, make your own class derived from the respective SUExxxxHandler overriding its virtual functions as necessary.

Sophisticated TCP Clients and Servers

Besides the basic event handling classes, the library includes some support for higher level abstractions such as TCP sessions.

Take a look at the following classes:

If you want to create a duplex protocol session over a transport other than TCP (e.g., a socket from AF_UNIX communication domain), you might want to look at the SUEGenericDuplexSession class as well.

Learn from samples

It is well-known that the best way to learn something is to look at a good example and try to repeat it. Here are some working demo programs which come along with the library.

The example sleep5.cpp is perhaps the simplest event-driven application ever made. It is intended to give you the basic idea how to work with SUEEventSelector and its company.

Another example, sitter.cpp, is probably more interesting for you because it uses two different types of events. First, it uses timeouts, just like the previous one (but it changes the moment from time to time). Second, it handles the event of arriving data on the standard input.

Yet another example, chat.cpp, is a very simple sample of a multiclient TCP server. It is a chat room. You can learn how to use the SUETcpServer and SUETcpServerSession classes (or, more precisely, how to create appropriate childern of them and use the children, not the classes themselves).

Well if you need to make your application to work as a TCP client rather than server (or even a client to one and server to another), take a look at hellobot.cpp, which demonstrates the SUETcpClientSession class. It is a bot for the previous example. The bot connects to the server and greets everyone who joins the chat room.

The last two sample programs are sigs.cpp and children.cpp; they are to give you an idea on handling unix signals (and, as a special case, the SIGCHLD signal) with SUE.


Generated on Sun May 16 00:42:49 2004 for SUE Library by doxygen1.2.18