ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/host/c++/SubNet.cpp
(Generate patch)

Comparing projects/cms/source/host/c++/SubNet.cpp (file contents):
Revision 1.3 by ab11, Fri Mar 23 14:09:57 2001 UTC vs.
Revision 1.5 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 "SubNet.h"
21  
22   SubNet::~SubNet(){
23      
24 +    // free up any allocated memory
25      delete socket;
26      delete udp;
27      
# Line 10 | Line 30 | SubNet::~SubNet(){
30   SubNet::SubNet(string host, int port){
31          // constructor
32  
13        socket = new iosockinet(sockbuf::sock_stream);
33          // create a pointer to the object
34 <
34 >        socket = new iosockinet(sockbuf::sock_stream);
35 >        
36 >    // make the actual connection
37          connect = (*socket).rdbuf()->connect(host.c_str(), port);
38                  
39   } // SubNet
# Line 25 | Line 46 | int SubNet::isConnected(){
46  
47  
48   SubNet::SubNet(){
49 +    // no arg constructor
50  
51 +    // connect to any socket on the local machine with the
52 +    // intention of getting sys information
53          socket = new iosockinet(sockbuf::sock_stream);
54          (*socket).rdbuf()->bind();
55          
# Line 35 | Line 59 | SubNet::SubNet(){
59  
60   string SubNet::sendTCP(string text){
61          
62 <        int size = 8192;
62 >        int size = 1024;
63          char buf[size];
64          
65          (*socket) << text.c_str() << "\n" << flush; //
66          
67 <        (*socket).getline (buf, size-1);
67 >        (*socket).getline(buf, size-1);
68          
69          return buf;
70          
# Line 48 | Line 72 | string SubNet::sendTCP(string text){
72  
73  
74   void SubNet::sendUPDPacket( string host, int port, string message ){
75 <        
76 <                int udpSize;
53 <        udpSize = 8129; // 8kb in bits (8192*8)
54 <        
55 <        udp = new osockinet(sockbuf::sock_dgram);  
56 <        (*udp)->setopt(sockbuf::so_sndbuf , &udpSize, sizeof(udpSize), sockbuf::sol_socket);
57 <
58 <        (*udp)->connect (host.c_str(), port);
59 <        (*udp) << message.c_str() << flush;
75 >
76 >    int udpSize = sizeof(message.c_str());
77      
78 <        delete udp;
78 >        udp = new osockinet(sockbuf::sock_dgram);  
79 >        (*udp)->setopt(sockbuf::so_sndbuf , &udpSize, sizeof(udpSize), sockbuf::sol_socket);
80 >
81 >        (*udp)->connect (host.c_str(), port);
82 >        (*udp) << message.c_str() << flush;
83 >
84 >        delete udp;
85      
86          return;
87          
88   } // sendUPDPacket
89  
67 string SubNet::getIPfromHost(string hostname){
68        return "";
69
70 } // getIPFromHost
71
72 string SubNet::getHostName(){
73        
74        string myHost = (*socket)->localhost();
75        delete socket;
76        return myHost;
77        
78
79 } // getHostName
80
81 string SubNet::getHostIP(){
82        return "";
83
84 } // getHostIP

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines