--- projects/cms/source/host/c++/SmallNet.cpp 2001/03/05 12:39:43 1.4 +++ projects/cms/source/host/c++/SmallNet.cpp 2002/05/21 16:47:11 1.7 @@ -1,3 +1,23 @@ +/* + * i-scream central monitoring system + * http://www.i-scream.org.uk + * Copyright (C) 2000-2002 i-scream + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + #include "SmallNet.h" SmallNet::SmallNet(int printDebug){ @@ -6,7 +26,7 @@ SmallNet::SmallNet(int printDebug){ if ( debug == 1 ){ std::cout << "SmallNet Constructor\n"; - } + } // if return; @@ -15,10 +35,9 @@ SmallNet::SmallNet(int printDebug){ int SmallNet::connectHeartBeat(string host, int port){ - if ( debug == 1 ){ std::cout << "SmallNet::connectHeartBeat(" << host << "," << port << ")\n"; - } + } // if ssocket = new SubNet(host, port); @@ -27,18 +46,13 @@ int SmallNet::connectHeartBeat(string host, int port){ } // connectHeartBeat string SmallNet::heartBeatSend(string text){ - - - - // char buf[1024]; - + if ( debug == 1 ){ std::cout << "SmallNet::heartBeatSend()\n"; - } + } // if return ssocket->sendTCP(text); - } // heartBeatSend @@ -46,7 +60,7 @@ void SmallNet::closeHeartBeatConnection(){ if ( debug == 1 ){ std::cout << "SmallNet::closeHeartBeatConnection()\n"; std::cout << "Deleting socket\n"; - } + } // if // closes automatically delete ssocket; @@ -58,7 +72,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); @@ -67,7 +81,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); @@ -76,45 +90,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 - // hard coding for testing - /* - host = "raptor.ukc.ac.uk"; - port = 7776; - */ - - ssocket = new SubNet(); - ssocket->sendUPDPacket(host, port, message); - delete ssocket; - - return; -} - -string SmallNet::getHostName(){ - - ssocket = new SubNet(); - string name = ssocket->getHostName(); + ssocket = new SubNet(); + ssocket->sendUPDPacket(host, port, message); delete ssocket; - return name; -} -string SmallNet::getHostIP(){ - - // (*socket).rdbuf()->bind(); - // return (*socket)->localaddr(); - return ""; -} \ No newline at end of file + return; +} // sendUDPPacket