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.6 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 "SubNet.h"
22  
23   SubNet::~SubNet(){
24      
25 +    // free up any allocated memory
26      delete socket;
27      delete udp;
28      
# Line 10 | Line 31 | SubNet::~SubNet(){
31   SubNet::SubNet(string host, int port){
32          // constructor
33  
13        socket = new iosockinet(sockbuf::sock_stream);
34          // create a pointer to the object
35 <
35 >        socket = new iosockinet(sockbuf::sock_stream);
36 >        
37 >    // make the actual connection
38          connect = (*socket).rdbuf()->connect(host.c_str(), port);
39                  
40   } // SubNet
# Line 25 | Line 47 | int SubNet::isConnected(){
47  
48  
49   SubNet::SubNet(){
50 +    // no arg constructor
51  
52 +    // connect to any socket on the local machine with the
53 +    // intention of getting sys information
54          socket = new iosockinet(sockbuf::sock_stream);
55          (*socket).rdbuf()->bind();
56          
# Line 35 | Line 60 | SubNet::SubNet(){
60  
61   string SubNet::sendTCP(string text){
62          
63 <        int size = 8192;
63 >        int size = 1024;
64          char buf[size];
65          
66          (*socket) << text.c_str() << "\n" << flush; //
67          
68 <        (*socket).getline (buf, size-1);
68 >        (*socket).getline(buf, size-1);
69          
70          return buf;
71          
# Line 48 | Line 73 | string SubNet::sendTCP(string text){
73  
74  
75   void SubNet::sendUPDPacket( string host, int port, string message ){
76 <        
77 <                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;
76 >
77 >    int udpSize = sizeof(message.c_str());
78      
79 <        delete udp;
79 >        udp = new osockinet(sockbuf::sock_dgram);  
80 >        (*udp)->setopt(sockbuf::so_sndbuf , &udpSize, sizeof(udpSize), sockbuf::sol_socket);
81 >
82 >        (*udp)->connect (host.c_str(), port);
83 >        (*udp) << message.c_str() << flush;
84 >
85 >        delete udp;
86      
87          return;
88          
89   } // sendUPDPacket
90  
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