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.1 by ab11, Wed Jan 24 19:33:13 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(){
22 > SmallNet::SmallNet(int printDebug){
23          
24 +        debug = printDebug;
25 +        
26 +        if ( debug == 1 ){
27 +                std::cout << "SmallNet Constructor\n";
28 +        } // if
29 +        
30          return;
31          
32 < }; // SmallNet
32 > } // SmallNet
33  
34  
35   int SmallNet::connectHeartBeat(string host, int port){
36          
37 +        if ( debug == 1 ){
38 +                std::cout << "SmallNet::connectHeartBeat(" << host << "," << port << ")\n";
39 +        } // if
40          
41 <        return 0;
41 >        ssocket = new SubNet(host, port);
42          
43 < }; // connectHeartBeat
43 >        return ssocket->isConnected();
44 >        
45 > } // connectHeartBeat
46  
17
47   string SmallNet::heartBeatSend(string text){
48 +                
49 +        if ( debug == 1 ){
50 +                std::cout << "SmallNet::heartBeatSend()\n";
51 +        } // if
52          
53 +        return ssocket->sendTCP(text);
54          
55 <        return "";
22 <        
23 < }; // heartBeatSend
55 > } // heartBeatSend
56  
57  
58   void SmallNet::closeHeartBeatConnection(){
59 +        if ( debug == 1 ){
60 +                std::cout << "SmallNet::closeHeartBeatConnection()\n";
61 +                std::cout << "Deleting socket\n";
62 +        } // if
63          
64 <        
64 >        // closes automatically
65 >        delete ssocket;
66          return;
67          
68 < }; // closeHeartBeatConnection  
68 > } // closeHeartBeatConnection  
69  
70  
71 < int SmallNet::connectConfig(){
71 > int SmallNet::connectConfig(string host, int port){
72 >        if ( debug == 1 ){
73 >                std::cout << "SmallNet::connectConfig(" << host << "," << port << ")\n";
74 >        } // if
75          
76 +        return connectHeartBeat(host,port);
77          
78 <        return 0;
38 <        
39 < }; // makeConfigConnection
78 > } // makeConfigConnection
79  
80   string SmallNet::configSend(string text){
81 +        if ( debug == 1 ){
82 +                std::cout << "SmallNet::configSend()\n";
83 +        } // if
84 +                
85 +        return heartBeatSend(text);
86          
87 + } // configSend
88 +
89 + void SmallNet::closeConfigConnection(){
90 +        if ( debug == 1 ){
91 +                std::cout << "SmallNet::closeConfigConnection()\n";
92 +        } // if
93          
94 +        closeHeartBeatConnection();
95          
96 <        return "";
96 >    return;
97          
98 < }; // configSend
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 +        } // if
105 +        
106 +        ssocket = new SubNet();
107 +        ssocket->sendUPDPacket(host, port, message);
108 +        delete ssocket;
109 +
110 +        return;
111 + } // sendUDPPacket

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines