ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/c++/SmallNet.cpp
(Generate patch)

Comparing projects/cms/source/host/c++/SmallNet.cpp (file contents):
Revision 1.3 by ab11, Mon Feb 26 14:55:51 2001 UTC vs.
Revision 1.6 by tdb, Sat May 18 18:15:56 2002 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * Copyright (C) 2000-2002 i-scream
4 + *
5 + * This program is free software; you can redistribute it and/or
6 + * modify it under the terms of the GNU General Public License
7 + * as published by the Free Software Foundation; either version 2
8 + * of the License, or (at your option) any later version.
9 + *
10 + * This program is distributed in the hope that it will be useful,
11 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 + * GNU General Public License for more details.
14 + *
15 + * You should have received a copy of the GNU General Public License
16 + * along with this program; if not, write to the Free Software
17 + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 + */
19 +
20   #include "SmallNet.h"
21  
22   SmallNet::SmallNet(int printDebug){
# Line 6 | Line 25 | SmallNet::SmallNet(int printDebug){
25          
26          if ( debug == 1 ){
27                  std::cout << "SmallNet Constructor\n";
28 <        }
28 >        } // if
29          
30          return;
31          
# Line 15 | Line 34 | SmallNet::SmallNet(int printDebug){
34  
35   int SmallNet::connectHeartBeat(string host, int port){
36          
18        
37          if ( debug == 1 ){
38                  std::cout << "SmallNet::connectHeartBeat(" << host << "," << port << ")\n";
39 <        }
39 >        } // if
40          
41 <        socket = new iosockinet(sockbuf::sock_stream);
24 <        // create a pointer to the object
41 >        ssocket = new SubNet(host, port);
42          
43 <        // connect the socket
43 >        return ssocket->isConnected();
44          
28        // std::cout << socket;
29        
30        return (*socket).rdbuf()->connect(host.c_str(), port);
31        
45   } // connectHeartBeat
46  
47   string SmallNet::heartBeatSend(string text){
48 <        
36 <        char  buf[1024];
37 <        
48 >                
49          if ( debug == 1 ){
50                  std::cout << "SmallNet::heartBeatSend()\n";
51 <        }
51 >        } // if
52          
53 <        // std::cout << socket;
43 <        // (*socket) << "BUNG BUNG BUNG" << flush;
44 <        (*socket) << text.c_str() << "\n" << flush; //
53 >        return ssocket->sendTCP(text);
54          
46        if ( debug == 1 ){
47                std::cout << "SmallNet::heartBeatSend->Sent:" << text << "\n";
48        }
49        
50        
51        (*socket).getline (buf, 1024);
52        
53        return buf;
54        
55   } // heartBeatSend
56  
57  
58   void SmallNet::closeHeartBeatConnection(){
59          if ( debug == 1 ){
60                  std::cout << "SmallNet::closeHeartBeatConnection()\n";
61 <        }
61 >                std::cout << "Deleting socket\n";
62 >        } // if
63          
64          // closes automatically
65 <        // socket.close();
65 >        delete ssocket;
66          return;
67          
68   } // closeHeartBeatConnection  
# Line 70 | Line 71 | void SmallNet::closeHeartBeatConnection(){
71   int SmallNet::connectConfig(string host, int port){
72          if ( debug == 1 ){
73                  std::cout << "SmallNet::connectConfig(" << host << "," << port << ")\n";
74 <        }
74 >        } // if
75          
76          return connectHeartBeat(host,port);
77          
# Line 79 | Line 80 | int SmallNet::connectConfig(string host, int port){
80   string SmallNet::configSend(string text){
81          if ( debug == 1 ){
82                  std::cout << "SmallNet::configSend()\n";
83 <        }
83 >        } // if
84                  
85          return heartBeatSend(text);
86          
# Line 88 | Line 89 | string SmallNet::configSend(string text){
89   void SmallNet::closeConfigConnection(){
90          if ( debug == 1 ){
91                  std::cout << "SmallNet::closeConfigConnection()\n";
92 <        }
92 >        } // if
93          
94          closeHeartBeatConnection();
95          
96      return;
97          
98 < }
98 > } // closeConfigConnection
99  
100   void SmallNet::sendUPDPacket( string host, int port, string message ){
101          
102          if ( debug == 1 ){
103                  std::cout << "SmallNet::sendUPDPacket:" << host << ":" << port << "\n";
104 <                std::cout << message << "\n";
104 <        }
104 >        } // if
105          
106 <        osockinet udpSocket(sockbuf::sock_dgram);
107 <        int udpSize;
108 <        udpSize = 8192;
109 <        udpSocket->setopt(sockbuf::so_sndbuf , &udpSize, sizeof(udpSize), sockbuf::sol_socket);
110 <        udpSocket->connect (host.c_str(), port);
111 <        udpSocket << message.c_str() << endl;
112 <    
106 >        ssocket = new SubNet();
107 >        ssocket->sendUPDPacket(host, port, message);
108 >        delete ssocket;
109 >
110          return;
111 < }
111 > } // sendUDPPacket

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines