ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/c++/SmallNet.cpp
Revision: 1.7
Committed: Tue May 21 16:47:11 2002 UTC (22 years, 6 months ago) by tdb
Branch: MAIN
Changes since 1.6: +1 -0 lines
Log Message:
Added URL to GPL headers.

File Contents

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