O'Reilly logo

Advanced UNIX Programming by Warren W. Gay

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Applying Message Queues

A client and server program that uses message queues is presented here. The client issues the request, and the server receives the message and responds. The server simply performs a stat(2) or lstat(2) call, and returns the results to the client by a message.

The client and server programs both use a C++ object that has been created to make using message queues a little friendlier. The C++ object and its implementation will be presented first.

Listing 23.1 shows the file msq.h, which defines the C++ class Msq.

Code Listing 23.1. msq.h—The Msq Class Definition File
 1: // msq.h : 2: // 3: // Message Queue Class : 4: 5: #include <sys/types.h> 6: #include <sys/ipc.h> 7: #include <sys/msg.h> 8: 9: struct Msg { 10: long msgtyp; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required