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.7 by tdb, Tue May 21 16:47:11 2002 UTC

# Line 1 | Line 1
1 + /*
2 + * i-scream central monitoring system
3 + * http://www.i-scream.org.uk
4 + * 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   #include "SmallNet.h"
22  
23   SmallNet::SmallNet(int printDebug){
# Line 6 | Line 26 | SmallNet::SmallNet(int printDebug){
26          
27          if ( debug == 1 ){
28                  std::cout << "SmallNet Constructor\n";
29 <        }
29 >        } // if
30          
31          return;
32          
# Line 15 | Line 35 | SmallNet::SmallNet(int printDebug){
35  
36   int SmallNet::connectHeartBeat(string host, int port){
37          
18        
38          if ( debug == 1 ){
39                  std::cout << "SmallNet::connectHeartBeat(" << host << "," << port << ")\n";
40 <        }
40 >        } // if
41          
42 <        socket = new iosockinet(sockbuf::sock_stream);
24 <        // create a pointer to the object
42 >        ssocket = new SubNet(host, port);
43          
44 <        // connect the socket
44 >        return ssocket->isConnected();
45          
28        // std::cout << socket;
29        
30        return (*socket).rdbuf()->connect(host.c_str(), port);
31        
46   } // connectHeartBeat
47  
48   string SmallNet::heartBeatSend(string text){
49 <        
36 <        char  buf[1024];
37 <        
49 >                
50          if ( debug == 1 ){
51                  std::cout << "SmallNet::heartBeatSend()\n";
52 <        }
52 >        } // if
53          
54 <        // std::cout << socket;
43 <        // (*socket) << "BUNG BUNG BUNG" << flush;
44 <        (*socket) << text.c_str() << "\n" << flush; //
54 >        return ssocket->sendTCP(text);
55          
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        
56   } // heartBeatSend
57  
58  
59   void SmallNet::closeHeartBeatConnection(){
60          if ( debug == 1 ){
61                  std::cout << "SmallNet::closeHeartBeatConnection()\n";
62 <        }
62 >                std::cout << "Deleting socket\n";
63 >        } // if
64          
65          // closes automatically
66 <        // socket.close();
66 >        delete ssocket;
67          return;
68          
69   } // closeHeartBeatConnection  
# Line 70 | Line 72 | void SmallNet::closeHeartBeatConnection(){
72   int SmallNet::connectConfig(string host, int port){
73          if ( debug == 1 ){
74                  std::cout << "SmallNet::connectConfig(" << host << "," << port << ")\n";
75 <        }
75 >        } // if
76          
77          return connectHeartBeat(host,port);
78          
# Line 79 | Line 81 | int SmallNet::connectConfig(string host, int port){
81   string SmallNet::configSend(string text){
82          if ( debug == 1 ){
83                  std::cout << "SmallNet::configSend()\n";
84 <        }
84 >        } // if
85                  
86          return heartBeatSend(text);
87          
# Line 88 | Line 90 | string SmallNet::configSend(string text){
90   void SmallNet::closeConfigConnection(){
91          if ( debug == 1 ){
92                  std::cout << "SmallNet::closeConfigConnection()\n";
93 <        }
93 >        } // if
94          
95          closeHeartBeatConnection();
96          
97      return;
98          
99 < }
99 > } // closeConfigConnection
100  
101   void SmallNet::sendUPDPacket( string host, int port, string message ){
102          
103          if ( debug == 1 ){
104                  std::cout << "SmallNet::sendUPDPacket:" << host << ":" << port << "\n";
105 <                std::cout << message << "\n";
104 <        }
105 >        } // if
106          
107 <        osockinet udpSocket(sockbuf::sock_dgram);
108 <        int udpSize;
109 <        udpSize = 8192;
110 <        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 <    
107 >        ssocket = new SubNet();
108 >        ssocket->sendUPDPacket(host, port, message);
109 >        delete ssocket;
110 >
111          return;
112 < }
112 > } // sendUDPPacket

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines