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.1 by ab11, Mon Mar 5 14:02:27 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 +    
29 + } // ~SubNet
30 +
31   SubNet::SubNet(string host, int port){
32          // constructor
33  
6        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 18 | 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 28 | Line 60 | SubNet::SubNet(){
60  
61   string SubNet::sendTCP(string text){
62          
63 <        char  buf[1024];
63 >        int size = 1024;
64 >        char buf[size];
65          
66          (*socket) << text.c_str() << "\n" << flush; //
67          
68 <        (*socket).getline (buf, 1024);
68 >        (*socket).getline(buf, size-1);
69          
70          return buf;
71          
# Line 40 | Line 73 | string SubNet::sendTCP(string text){
73  
74  
75   void SubNet::sendUPDPacket( string host, int port, string message ){
76 <        
77 <        /*
45 <        host = "raptor.ukc.ac.uk";
46 <        port = 7776;
47 <        */
48 <        
49 <        int udpSize;
50 <        udpSize = 65536; // 8kb in bits (8192*8)
51 <        
52 <        udp = new osockinet(sockbuf::sock_dgram);  
53 <        (*udp)->setopt(sockbuf::so_sndbuf , &udpSize, sizeof(udpSize), sockbuf::sol_socket);
54 <
55 <        // int sndBufSize = (*udp)->sendbufsz(udpSize);
56 <        
57 <        (*udp)->connect (host.c_str(), port);
58 <        (*udp) << message.c_str() << endl;
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  
66 string SubNet::getIPfromHost(string hostname){
67        return "";
68
69 } // getIPFromHost
70
71 string SubNet::getHostName(){
72        
73        string myHost = (*socket)->localhost();
74        delete socket;
75        return myHost;
76        
77
78 } // getHostName
79
80 string SubNet::getHostIP(){
81        return "";
82
83 } // getHostIP

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines