ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/c++/SmallNet.cpp
Revision: 1.6
Committed: Sat May 18 18:15:56 2002 UTC (22 years, 4 months ago) by tdb
Branch: MAIN
Changes since 1.5: +19 -0 lines
Log Message:
i-scream is now licensed under the GPL. I've added the GPL headers to every
source file, and put a full copy of the license in the appropriate places.
I think I've covered everything. This is going to be a mad commit ;)

File Contents

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