///////////////////////////////////////////////////////////////////////// // Server.cpp - Tests asynchronous message-passing IPC using // // ver 1.1 // // Language: Visual C++ 2008 // // Platform: Dell Precision T7400, Vista Ultimate, SP1 // // Application: Help for CSE687 - Object Oriented Design, Project #2 // // Author: Jim Fawcett, CST 4-187, Syracuse University // // (315) 443-3948, jfawcett@twcny.rr.com // ///////////////////////////////////////////////////////////////////////// /* * Module Operations: * ================== * Test asynchronous message-passing using the MessageMgr and MMFmgr * modules. * * Note: * Server should call MsgMgr::wait() to wait for server to come up * before sending or waiting for messages. * * Required Files: * Client.cpp, Server.cpp, MessageMgr.h, MessageMgr.cpp, MMFmgr.h, MMFmgr.cpp, * Threads.h, Threads.cpp, BlockingQueue.h, locks.h * * Build Command: * cl /EHa Client.cpp MessageMgr.cpp MMFmgr.cpp Threads.cpp * cl /EHa Server.cpp MessageMgr.cpp MMFmgr.cpp Threads.cpp * * Maintenance History: * ver 1.1 : 26 Mar 09 * - removed debugString references and some no longer needed includes. * - fixed a problem with project references to threads and locks modules * ver 1.0 : 22 Mar 09 * - first release */ #include "..\MessageMgr\MessageMgr.h" #include #include void main() { sout << "\n Server using Message-Passing IPC facility"; sout << "\n ===========================================\n"; try { MsgMgr server(MMFmgr::server); server.wait(); sout << "\n client started"; sout << "\n waiting for opening message"; std::string msg = server.getMessage(); sout << locker << "\n message is: " << msg.c_str() << unlocker; sout.flush(); msg = "2nd "; sout << locker << "\n sending message: " << msg << "\n" << unlocker; server.putMessage(msg); while(true) { std::string msg = server.getMessage(); sout << "\n " << msg.c_str(); if(msg == "quit") break; } sout << "\n\n"; } catch(std::exception& ex) { sout << ex.what(); } }