--- projects/cms/source/host/c++/SmallNet.cpp 2001/02/26 14:55:51 1.3 +++ projects/cms/source/host/c++/SmallNet.cpp 2001/03/27 00:05:08 1.5 @@ -6,7 +6,7 @@ SmallNet::SmallNet(int printDebug){ if ( debug == 1 ){ std::cout << "SmallNet Constructor\n"; - } + } // if return; @@ -15,53 +15,35 @@ SmallNet::SmallNet(int printDebug){ int SmallNet::connectHeartBeat(string host, int port){ - if ( debug == 1 ){ std::cout << "SmallNet::connectHeartBeat(" << host << "," << port << ")\n"; - } + } // if - socket = new iosockinet(sockbuf::sock_stream); - // create a pointer to the object + ssocket = new SubNet(host, port); - // connect the socket + return ssocket->isConnected(); - // std::cout << socket; - - return (*socket).rdbuf()->connect(host.c_str(), port); - } // connectHeartBeat string SmallNet::heartBeatSend(string text){ - - char buf[1024]; - + if ( debug == 1 ){ std::cout << "SmallNet::heartBeatSend()\n"; - } + } // if - // std::cout << socket; - // (*socket) << "BUNG BUNG BUNG" << flush; - (*socket) << text.c_str() << "\n" << flush; // + return ssocket->sendTCP(text); - if ( debug == 1 ){ - std::cout << "SmallNet::heartBeatSend->Sent:" << text << "\n"; - } - - - (*socket).getline (buf, 1024); - - return buf; - } // heartBeatSend void SmallNet::closeHeartBeatConnection(){ if ( debug == 1 ){ std::cout << "SmallNet::closeHeartBeatConnection()\n"; - } + std::cout << "Deleting socket\n"; + } // if // closes automatically - // socket.close(); + delete ssocket; return; } // closeHeartBeatConnection @@ -70,7 +52,7 @@ void SmallNet::closeHeartBeatConnection(){ int SmallNet::connectConfig(string host, int port){ if ( debug == 1 ){ std::cout << "SmallNet::connectConfig(" << host << "," << port << ")\n"; - } + } // if return connectHeartBeat(host,port); @@ -79,7 +61,7 @@ int SmallNet::connectConfig(string host, int port){ string SmallNet::configSend(string text){ if ( debug == 1 ){ std::cout << "SmallNet::configSend()\n"; - } + } // if return heartBeatSend(text); @@ -88,27 +70,23 @@ string SmallNet::configSend(string text){ void SmallNet::closeConfigConnection(){ if ( debug == 1 ){ std::cout << "SmallNet::closeConfigConnection()\n"; - } + } // if closeHeartBeatConnection(); return; -} +} // closeConfigConnection void SmallNet::sendUPDPacket( string host, int port, string message ){ if ( debug == 1 ){ std::cout << "SmallNet::sendUPDPacket:" << host << ":" << port << "\n"; - std::cout << message << "\n"; - } + } // if - osockinet udpSocket(sockbuf::sock_dgram); - int udpSize; - udpSize = 8192; - udpSocket->setopt(sockbuf::so_sndbuf , &udpSize, sizeof(udpSize), sockbuf::sol_socket); - udpSocket->connect (host.c_str(), port); - udpSocket << message.c_str() << endl; - + ssocket = new SubNet(); + ssocket->sendUPDPacket(host, port, message); + delete ssocket; + return; -} \ No newline at end of file +} // sendUDPPacket