6 |
|
|
7 |
|
if ( debug == 1 ){ |
8 |
|
std::cout << "SmallNet Constructor\n"; |
9 |
< |
} |
9 |
> |
} // if |
10 |
|
|
11 |
|
return; |
12 |
|
|
15 |
|
|
16 |
|
int SmallNet::connectHeartBeat(string host, int port){ |
17 |
|
|
18 |
– |
|
18 |
|
if ( debug == 1 ){ |
19 |
|
std::cout << "SmallNet::connectHeartBeat(" << host << "," << port << ")\n"; |
20 |
< |
} |
20 |
> |
} // if |
21 |
|
|
22 |
|
ssocket = new SubNet(host, port); |
23 |
|
|
26 |
|
} // connectHeartBeat |
27 |
|
|
28 |
|
string SmallNet::heartBeatSend(string text){ |
29 |
< |
|
31 |
< |
|
32 |
< |
|
33 |
< |
// char buf[1024]; |
34 |
< |
|
29 |
> |
|
30 |
|
if ( debug == 1 ){ |
31 |
|
std::cout << "SmallNet::heartBeatSend()\n"; |
32 |
< |
} |
32 |
> |
} // if |
33 |
|
|
34 |
|
return ssocket->sendTCP(text); |
35 |
|
|
41 |
– |
|
36 |
|
} // heartBeatSend |
37 |
|
|
38 |
|
|
40 |
|
if ( debug == 1 ){ |
41 |
|
std::cout << "SmallNet::closeHeartBeatConnection()\n"; |
42 |
|
std::cout << "Deleting socket\n"; |
43 |
< |
} |
43 |
> |
} // if |
44 |
|
|
45 |
|
// closes automatically |
46 |
|
delete ssocket; |
52 |
|
int SmallNet::connectConfig(string host, int port){ |
53 |
|
if ( debug == 1 ){ |
54 |
|
std::cout << "SmallNet::connectConfig(" << host << "," << port << ")\n"; |
55 |
< |
} |
55 |
> |
} // if |
56 |
|
|
57 |
|
return connectHeartBeat(host,port); |
58 |
|
|
61 |
|
string SmallNet::configSend(string text){ |
62 |
|
if ( debug == 1 ){ |
63 |
|
std::cout << "SmallNet::configSend()\n"; |
64 |
< |
} |
64 |
> |
} // if |
65 |
|
|
66 |
|
return heartBeatSend(text); |
67 |
|
|
70 |
|
void SmallNet::closeConfigConnection(){ |
71 |
|
if ( debug == 1 ){ |
72 |
|
std::cout << "SmallNet::closeConfigConnection()\n"; |
73 |
< |
} |
73 |
> |
} // if |
74 |
|
|
75 |
|
closeHeartBeatConnection(); |
76 |
|
|
77 |
|
return; |
78 |
|
|
79 |
< |
} |
79 |
> |
} // closeConfigConnection |
80 |
|
|
81 |
|
void SmallNet::sendUPDPacket( string host, int port, string message ){ |
82 |
|
|
83 |
|
if ( debug == 1 ){ |
84 |
|
std::cout << "SmallNet::sendUPDPacket:" << host << ":" << port << "\n"; |
85 |
< |
// std::cout << message << "\n"; |
92 |
< |
} |
85 |
> |
} // if |
86 |
|
|
87 |
< |
// hard coding for testing |
88 |
< |
/* |
96 |
< |
host = "raptor.ukc.ac.uk"; |
97 |
< |
port = 7776; |
98 |
< |
*/ |
99 |
< |
|
100 |
< |
ssocket = new SubNet(); |
101 |
< |
ssocket->sendUPDPacket(host, port, message); |
102 |
< |
delete ssocket; |
103 |
< |
|
104 |
< |
return; |
105 |
< |
} |
106 |
< |
|
107 |
< |
string SmallNet::getHostName(){ |
108 |
< |
|
109 |
< |
ssocket = new SubNet(); |
110 |
< |
string name = ssocket->getHostName(); |
87 |
> |
ssocket = new SubNet(); |
88 |
> |
ssocket->sendUPDPacket(host, port, message); |
89 |
|
delete ssocket; |
112 |
– |
return name; |
113 |
– |
} |
90 |
|
|
91 |
< |
string SmallNet::getHostIP(){ |
92 |
< |
|
117 |
< |
// (*socket).rdbuf()->bind(); |
118 |
< |
// return (*socket)->localaddr(); |
119 |
< |
return ""; |
120 |
< |
} |
91 |
> |
return; |
92 |
> |
} // sendUDPPacket |