From 5689bb7f990f00b3aa0581dec11b51d3b9a79629 Mon Sep 17 00:00:00 2001 From: arno Date: Tue, 17 Nov 2009 07:56:14 +0000 Subject: [PATCH] - Fix for Win32 - Made server a DNS name in trial.cpp git-svn-id: https://ttuki.vtt.fi/svn/p2p-next/TUD/p2tp/trunk@566 e16421f0-f15b-0410-abcd-98678b794739 --- exec/trial.cpp | 17 ++++++++++++++++- ext/send_control.cpp | 28 ++++++++++++++++------------ 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/exec/trial.cpp b/exec/trial.cpp index dad4fa0..9e9b64d 100644 --- a/exec/trial.cpp +++ b/exec/trial.cpp @@ -27,8 +27,23 @@ int main (int argn, char** args) { std::string sfn = tmpdir+"team.jpg"; const char* filename = sfn.c_str(); + char servstr[256]; + struct hostent *h = gethostbyname("mughal.tribler.org"); + if (h == NULL) + { + print_error("cannot nslookup"); + return 1; + } + else + { + struct in_addr addr; + addr.s_addr = *(u_long *) h->h_addr_list[0]; + sprintf(servstr,"%s:%d", inet_ntoa(addr), 10000); + } + + printf("Server %s\n",servstr); - Address tracker("130.161.211.198:10000"), + Address tracker(servstr), bindaddr((uint32_t)INADDR_ANY,10000); if (0>p2tp::Listen(bindaddr)) { print_error("cannot bind"); diff --git a/ext/send_control.cpp b/ext/send_control.cpp index 495eb16..490ecfa 100644 --- a/ext/send_control.cpp +++ b/ext/send_control.cpp @@ -7,7 +7,11 @@ * */ #include "p2tp.h" - +#ifdef _MSC_VER + // To avoid complaints about std::max. Appears to work in VS2008 + #undef min + #undef max +#endif using namespace p2tp; @@ -51,7 +55,7 @@ KeepAliveController::KeepAliveController (Channel* ch) : SendController(ch), del } -KeepAliveController::KeepAliveController(SendController* prev, tint delay) : +KeepAliveController::KeepAliveController(SendController* prev, tint delay) : SendController(prev), delay_(delay) { ch_->dev_avg_ = TINT_SEC; // without constant active measurement, rtt is unreliable delay_=ch_->rtt_avg_; @@ -60,7 +64,7 @@ SendController(prev), delay_(delay) { bool KeepAliveController::MaySendData() { return true; } - + void KeepAliveController::OnDataSent(bin64_t b) { if (b==bin64_t::ALL || b==bin64_t::NONE) { @@ -76,21 +80,21 @@ void KeepAliveController::OnDataSent(bin64_t b) { Swap(new SlowStartController(this)); } } - + void KeepAliveController::OnDataRecvd(bin64_t b) { if (b!=bin64_t::NONE && b!=bin64_t::ALL) { // channel is alive delay_ = ch_->rtt_avg_; Schedule(NOW); // schedule an ACK; TODO: aggregate } } - + void KeepAliveController::OnAckRcvd(bin64_t ackd) { // probably to something sent by CwndControllers before this one got installed } - + CwndController::CwndController(SendController* orig, int cwnd) : -SendController(orig), cwnd_(cwnd), last_change_(0) { +SendController(orig), cwnd_(cwnd), last_change_(0) { } bool CwndController::MaySendData() { @@ -101,7 +105,7 @@ bool CwndController::MaySendData() { return ch_->data_out_.empty() || (ch_->data_out_.size() < cwnd_ && NOW-ch_->last_send_data_time_ >= spacing); } - + void CwndController::OnDataSent(bin64_t b) { if ( (b==bin64_t::ALL || b==bin64_t::NONE) && MaySendData() ) { // no more data (no hints?) @@ -126,7 +130,7 @@ void CwndController::OnDataRecvd(bin64_t b) { Schedule(NOW); // send ACK; todo: aggregate ACKs } } - + void CwndController::OnAckRcvd(bin64_t ackd) { if (ackd==bin64_t::NONE) { dprintf("%s #%i sendctrl loss detected\n",tintstr(),ch_->id); @@ -137,7 +141,7 @@ void CwndController::OnAckRcvd(bin64_t ackd) { } else { if (cwnd_<1) cwnd_ *= 2; - else + else cwnd_ += 1.0/cwnd_; dprintf("%s #%i sendctrl cwnd to %f\n",tintstr(),ch_->id,cwnd_); } @@ -153,7 +157,7 @@ void SlowStartController::OnAckRcvd (bin64_t pos) { Schedule(NOW); Swap(new AIMDController(this,cwnd_)); } - } else + } else cwnd_ /= 2; } - + -- 2.20.1