--- projects/cms/source/host/c++/SmallNet.cpp 2001/01/24 19:33:13 1.1 +++ projects/cms/source/host/c++/SmallNet.cpp 2001/03/27 00:05:08 1.5 @@ -1,48 +1,92 @@ #include "SmallNet.h" -SmallNet::SmallNet(){ +SmallNet::SmallNet(int printDebug){ + debug = printDebug; + + if ( debug == 1 ){ + std::cout << "SmallNet Constructor\n"; + } // if + return; -}; // SmallNet +} // SmallNet int SmallNet::connectHeartBeat(string host, int port){ + if ( debug == 1 ){ + std::cout << "SmallNet::connectHeartBeat(" << host << "," << port << ")\n"; + } // if - return 0; + ssocket = new SubNet(host, port); -}; // connectHeartBeat + return ssocket->isConnected(); + +} // connectHeartBeat - string SmallNet::heartBeatSend(string text){ + + if ( debug == 1 ){ + std::cout << "SmallNet::heartBeatSend()\n"; + } // if + return ssocket->sendTCP(text); - return ""; - -}; // heartBeatSend +} // heartBeatSend void SmallNet::closeHeartBeatConnection(){ + if ( debug == 1 ){ + std::cout << "SmallNet::closeHeartBeatConnection()\n"; + std::cout << "Deleting socket\n"; + } // if - + // closes automatically + delete ssocket; return; -}; // closeHeartBeatConnection +} // closeHeartBeatConnection -int SmallNet::connectConfig(){ +int SmallNet::connectConfig(string host, int port){ + if ( debug == 1 ){ + std::cout << "SmallNet::connectConfig(" << host << "," << port << ")\n"; + } // if + return connectHeartBeat(host,port); - return 0; - -}; // makeConfigConnection +} // makeConfigConnection string SmallNet::configSend(string text){ + if ( debug == 1 ){ + std::cout << "SmallNet::configSend()\n"; + } // if + + return heartBeatSend(text); +} // configSend + +void SmallNet::closeConfigConnection(){ + if ( debug == 1 ){ + std::cout << "SmallNet::closeConfigConnection()\n"; + } // if + closeHeartBeatConnection(); - return ""; + return; -}; // configSend +} // closeConfigConnection +void SmallNet::sendUPDPacket( string host, int port, string message ){ + + if ( debug == 1 ){ + std::cout << "SmallNet::sendUPDPacket:" << host << ":" << port << "\n"; + } // if + + ssocket = new SubNet(); + ssocket->sendUPDPacket(host, port, message); + delete ssocket; + + return; +} // sendUDPPacket