--- projects/cms/source/host/c++/SubNet.cpp 2001/03/23 14:09:57 1.3 +++ projects/cms/source/host/c++/SubNet.cpp 2001/03/27 00:04:55 1.4 @@ -2,6 +2,7 @@ SubNet::~SubNet(){ + // free up any allocated memory delete socket; delete udp; @@ -10,9 +11,10 @@ SubNet::~SubNet(){ SubNet::SubNet(string host, int port){ // constructor - socket = new iosockinet(sockbuf::sock_stream); // create a pointer to the object - + socket = new iosockinet(sockbuf::sock_stream); + + // make the actual connection connect = (*socket).rdbuf()->connect(host.c_str(), port); } // SubNet @@ -25,7 +27,10 @@ int SubNet::isConnected(){ SubNet::SubNet(){ + // no arg constructor + // connect to any socket on the local machine with the + // intention of getting sys information socket = new iosockinet(sockbuf::sock_stream); (*socket).rdbuf()->bind(); @@ -35,12 +40,12 @@ SubNet::SubNet(){ string SubNet::sendTCP(string text){ - int size = 8192; + int size = 1024; char buf[size]; (*socket) << text.c_str() << "\n" << flush; // - (*socket).getline (buf, size-1); + (*socket).getline(buf, size-1); return buf; @@ -48,37 +53,18 @@ string SubNet::sendTCP(string text){ void SubNet::sendUPDPacket( string host, int port, string message ){ - - int udpSize; - udpSize = 8129; // 8kb in bits (8192*8) - - udp = new osockinet(sockbuf::sock_dgram); - (*udp)->setopt(sockbuf::so_sndbuf , &udpSize, sizeof(udpSize), sockbuf::sol_socket); - - (*udp)->connect (host.c_str(), port); - (*udp) << message.c_str() << flush; + + int udpSize = sizeof(message.c_str()); - delete udp; + udp = new osockinet(sockbuf::sock_dgram); + (*udp)->setopt(sockbuf::so_sndbuf , &udpSize, sizeof(udpSize), sockbuf::sol_socket); + + (*udp)->connect (host.c_str(), port); + (*udp) << message.c_str() << flush; + + delete udp; return; } // sendUPDPacket -string SubNet::getIPfromHost(string hostname){ - return ""; - -} // getIPFromHost - -string SubNet::getHostName(){ - - string myHost = (*socket)->localhost(); - delete socket; - return myHost; - - -} // getHostName - -string SubNet::getHostIP(){ - return ""; - -} // getHostIP \ No newline at end of file