ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/c++/SmallNet.cpp
Revision: 1.5
Committed: Tue Mar 27 00:05:08 2001 UTC (23 years, 6 months ago) by ab11
Branch: MAIN
CVS Tags: PROJECT_COMPLETION
Changes since 1.4: +14 -42 lines
Log Message:
tidied up

File Contents

# User Rev Content
1 ab11 1.1 #include "SmallNet.h"
2    
3 ab11 1.3 SmallNet::SmallNet(int printDebug){
4    
5     debug = printDebug;
6    
7     if ( debug == 1 ){
8     std::cout << "SmallNet Constructor\n";
9 ab11 1.5 } // if
10 ab11 1.1
11     return;
12    
13 ab11 1.3 } // SmallNet
14 ab11 1.1
15    
16     int SmallNet::connectHeartBeat(string host, int port){
17    
18 ab11 1.3 if ( debug == 1 ){
19     std::cout << "SmallNet::connectHeartBeat(" << host << "," << port << ")\n";
20 ab11 1.5 } // if
21 ab11 1.3
22 ab11 1.4 ssocket = new SubNet(host, port);
23 ab11 1.3
24 ab11 1.4 return ssocket->isConnected();
25 ab11 1.3
26     } // connectHeartBeat
27 ab11 1.1
28     string SmallNet::heartBeatSend(string text){
29 ab11 1.5
30 ab11 1.3 if ( debug == 1 ){
31 ab11 1.4 std::cout << "SmallNet::heartBeatSend()\n";
32 ab11 1.5 } // if
33 ab11 1.1
34 ab11 1.4 return ssocket->sendTCP(text);
35 ab11 1.1
36 ab11 1.3 } // heartBeatSend
37 ab11 1.1
38    
39     void SmallNet::closeHeartBeatConnection(){
40 ab11 1.3 if ( debug == 1 ){
41     std::cout << "SmallNet::closeHeartBeatConnection()\n";
42 ab11 1.4 std::cout << "Deleting socket\n";
43 ab11 1.5 } // if
44 ab11 1.1
45 ab11 1.3 // closes automatically
46 ab11 1.4 delete ssocket;
47 ab11 1.1 return;
48    
49 ab11 1.3 } // closeHeartBeatConnection
50 ab11 1.1
51    
52 ab11 1.3 int SmallNet::connectConfig(string host, int port){
53     if ( debug == 1 ){
54     std::cout << "SmallNet::connectConfig(" << host << "," << port << ")\n";
55 ab11 1.5 } // if
56 ab11 1.1
57 ab11 1.3 return connectHeartBeat(host,port);
58 ab11 1.1
59 ab11 1.3 } // makeConfigConnection
60 ab11 1.1
61     string SmallNet::configSend(string text){
62 ab11 1.3 if ( debug == 1 ){
63     std::cout << "SmallNet::configSend()\n";
64 ab11 1.5 } // if
65 ab11 1.3
66     return heartBeatSend(text);
67    
68     } // configSend
69    
70     void SmallNet::closeConfigConnection(){
71     if ( debug == 1 ){
72     std::cout << "SmallNet::closeConfigConnection()\n";
73 ab11 1.5 } // if
74 ab11 1.3
75     closeHeartBeatConnection();
76    
77     return;
78    
79 ab11 1.5 } // closeConfigConnection
80 ab11 1.3
81     void SmallNet::sendUPDPacket( string host, int port, string message ){
82    
83     if ( debug == 1 ){
84     std::cout << "SmallNet::sendUPDPacket:" << host << ":" << port << "\n";
85 ab11 1.5 } // if
86 ab11 1.4
87 ab11 1.5 ssocket = new SubNet();
88     ssocket->sendUPDPacket(host, port, message);
89 ab11 1.4 delete ssocket;
90    
91 ab11 1.5 return;
92     } // sendUDPPacket