| 1 |
|
#include "SubNet.h" |
| 2 |
|
|
| 3 |
+ |
SubNet::~SubNet(){ |
| 4 |
+ |
|
| 5 |
+ |
delete socket; |
| 6 |
+ |
delete udp; |
| 7 |
+ |
|
| 8 |
+ |
} // ~SubNet |
| 9 |
+ |
|
| 10 |
|
SubNet::SubNet(string host, int port){ |
| 11 |
|
// constructor |
| 12 |
|
|
| 35 |
|
|
| 36 |
|
string SubNet::sendTCP(string text){ |
| 37 |
|
|
| 38 |
< |
int size = 1024; |
| 39 |
< |
char buf[size]; |
| 38 |
> |
int size = 8192; |
| 39 |
> |
char buf[size]; |
| 40 |
|
|
| 41 |
|
(*socket) << text.c_str() << "\n" << flush; // |
| 42 |
|
|
| 49 |
|
|
| 50 |
|
void SubNet::sendUPDPacket( string host, int port, string message ){ |
| 51 |
|
|
| 52 |
< |
/* |
| 53 |
< |
host = "raptor.ukc.ac.uk"; |
| 47 |
< |
port = 7776; |
| 48 |
< |
*/ |
| 52 |
> |
int udpSize; |
| 53 |
> |
udpSize = 8129; // 8kb in bits (8192*8) |
| 54 |
|
|
| 50 |
– |
int udpSize; |
| 51 |
– |
udpSize = 65536; // 8kb in bits (8192*8) |
| 52 |
– |
|
| 55 |
|
udp = new osockinet(sockbuf::sock_dgram); |
| 56 |
|
(*udp)->setopt(sockbuf::so_sndbuf , &udpSize, sizeof(udpSize), sockbuf::sol_socket); |
| 57 |
|
|
| 58 |
< |
// int sndBufSize = (*udp)->sendbufsz(udpSize); |
| 59 |
< |
|
| 58 |
< |
(*udp)->connect (host.c_str(), port); |
| 59 |
< |
(*udp) << message.c_str() << flush << endl; |
| 58 |
> |
(*udp)->connect (host.c_str(), port); |
| 59 |
> |
(*udp) << message.c_str() << flush; |
| 60 |
|
|
| 61 |
|
delete udp; |
| 62 |
|
|