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.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 +    
28 + } // ~SubNet
29 +
30   SubNet::SubNet(string host, int port){
31          // constructor
32  
6        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 18 | 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 28 | Line 59 | SubNet::SubNet(){
59  
60   string SubNet::sendTCP(string text){
61          
62 <        char  buf[1024];
62 >        int size = 1024;
63 >        char buf[size];
64          
65          (*socket) << text.c_str() << "\n" << flush; //
66          
67 <        (*socket).getline (buf, 1024);
67 >        (*socket).getline(buf, size-1);
68          
69          return buf;
70          
# Line 40 | Line 72 | string SubNet::sendTCP(string text){
72  
73  
74   void SubNet::sendUPDPacket( string host, int port, string message ){
75 <        
76 <        /*
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;
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  
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