bool ClientMain::sendAndReceive ( const string  interface,
const Message request,
Message answer 
) throw (NetInterfaceException) [private]

Definition at line 466 of file ClientMain.cpp.

00466                                                                                                                             {
00467         // prepare a pointer to a net interface
00468         NetInterface* pNetInterface = 0;
00469         // decide which interface to chose
00470         if (!interface.compare("main")) {
00471                 pNetInterface = pMainNetInterface;
00472         }
00473         else if (!interface.compare("callback")) {
00474                 pNetInterface = pCallbackNetInterface;
00475         }
00476         else {
00477                 cout << DateFormater::getDate() << "Unknown net interface \"" << interface << "\". Can't connect..." << endl;
00478                 return false;
00479         }
00480         // connecting to the foreign host
00481         pNetInterface->connectTo();
00482         // sending the request as a format string
00483         pNetInterface->writeToBuffer(request.getFormatString());
00484         pNetInterface->write();
00485         pNetInterface->clearBuffer();
00486         // waiting for an answer until the timeout
00487         int readStatus = pNetInterface->readWithTimeout(40000,networkTimeout);
00488         string answerString = pNetInterface->readFromBuffer();
00489         pNetInterface->clearBuffer();
00490         pNetInterface->close();
00491         // has a timeout happened?
00492         if ( readStatus <= 0 ) {
00493                 cout << DateFormater::getDate() << "The server did not answer in time..." << endl;
00494                 return false;
00495         }
00496         // if something was received, form an object of it
00497         else {
00498                 answer = Message(answerString);
00499                 return true;
00500         }
00501 }


Generated on Wed Jun 25 14:47:08 2008 for keyvil by  doxygen 1.5.1