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.2 by ab11, Tue Mar 6 00:39:13 2001 UTC vs.
Revision 1.4 by ab11, Tue Mar 27 00:04:55 2001 UTC

# Line 1 | Line 1
1   #include "SubNet.h"
2  
3 + SubNet::~SubNet(){
4 +    
5 +    // free up any allocated memory
6 +    delete socket;
7 +    delete udp;
8 +    
9 + } // ~SubNet
10 +
11   SubNet::SubNet(string host, int port){
12          // constructor
13  
6        socket = new iosockinet(sockbuf::sock_stream);
14          // create a pointer to the object
15 <
15 >        socket = new iosockinet(sockbuf::sock_stream);
16 >        
17 >    // make the actual connection
18          connect = (*socket).rdbuf()->connect(host.c_str(), port);
19                  
20   } // SubNet
# Line 18 | Line 27 | int SubNet::isConnected(){
27  
28  
29   SubNet::SubNet(){
30 +    // no arg constructor
31  
32 +    // connect to any socket on the local machine with the
33 +    // intention of getting sys information
34          socket = new iosockinet(sockbuf::sock_stream);
35          (*socket).rdbuf()->bind();
36          
# Line 29 | Line 41 | SubNet::SubNet(){
41   string SubNet::sendTCP(string text){
42          
43          int size = 1024;
44 <        char  buf[size];
44 >        char buf[size];
45          
46          (*socket) << text.c_str() << "\n" << flush; //
47          
48 <        (*socket).getline (buf, size-1);
48 >        (*socket).getline(buf, size-1);
49          
50          return buf;
51          
# Line 41 | Line 53 | string SubNet::sendTCP(string text){
53  
54  
55   void SubNet::sendUPDPacket( string host, int port, string message ){
56 <        
57 <        /*
46 <        host = "raptor.ukc.ac.uk";
47 <        port = 7776;
48 <        */
49 <        
50 <        int udpSize;
51 <        udpSize = 65536; // 8kb in bits (8192*8)
52 <        
53 <        udp = new osockinet(sockbuf::sock_dgram);  
54 <        (*udp)->setopt(sockbuf::so_sndbuf , &udpSize, sizeof(udpSize), sockbuf::sol_socket);
55 <
56 <        // int sndBufSize = (*udp)->sendbufsz(udpSize);
57 <        
58 <        (*udp)->connect (host.c_str(), port);
59 <        (*udp) << message.c_str() << flush << endl;
56 >
57 >    int udpSize = sizeof(message.c_str());
58      
59 <        delete udp;
59 >        udp = new osockinet(sockbuf::sock_dgram);  
60 >        (*udp)->setopt(sockbuf::so_sndbuf , &udpSize, sizeof(udpSize), sockbuf::sol_socket);
61 >
62 >        (*udp)->connect (host.c_str(), port);
63 >        (*udp) << message.c_str() << flush;
64 >
65 >        delete udp;
66      
67          return;
68          
69   } // sendUPDPacket
70  
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