uint64_t pSocket::GetBytesR() { int64_t sz = GetBytesReceived() - m_last_r; m_last_r = GetBytesReceived(); m_last_r_buf[m_last_r_ptr++ % DLCHECKSIZE] = m_last_r; return sz; }
void OnLine(const std::string& line) { if (line == "") { struct timeval tv; Utility::GetTime(&tv); tv.tv_sec -= m_start.tv_sec; tv.tv_usec -= m_start.tv_usec; Utility::GetTime(&m_start); if (tv.tv_usec < 0) { tv.tv_usec += 1000000; tv.tv_sec -= 1; } double t = tv.tv_usec; t /= 1000000; t += tv.tv_sec; printf(" Time: %ld.%06ld (%f)\n", tv.tv_sec, tv.tv_usec, t); double r = GetBytesReceived(); printf(" bytes in: %lld (%f Mbytes/sec)\n", GetBytesReceived(true), r / t / 1000000); double s = GetBytesSent(); printf(" bytes out: %lld (%f Mbytes/sec)\n", GetBytesSent(true), s / t / 1000000); printf("\n"); } else if (line != "zzzzzzzzzmmmmmmmmm1234lkkk54" && line != "zzzzzzzzzmmmmmmmmm1234lkkk543") { printf("\n-------------------------------------------------------\n"); for (size_t i = 0; i < line.size(); i++) if (!isprint(line[i])) printf("<%d>", line[i]); else printf("%c", line[i]); printf("\n"); fflush(stdout); exit(-1); quit = true; } }
void OnWriteComplete() { printf("OnWriteComplete\n"); struct timeval tv; Utility::GetTime(&tv); tv.tv_sec -= m_start.tv_sec; tv.tv_usec -= m_start.tv_usec; Utility::GetTime(&m_start); if (tv.tv_usec < 0) { tv.tv_usec += 1000000; tv.tv_sec -= 1; } double t = tv.tv_usec; t /= 1000000; t += tv.tv_sec; printf(" Time: %ld.%06ld (%f)\n", tv.tv_sec, tv.tv_usec, t); double r = GetBytesReceived(); printf(" bytes in: %lld (%f Mbytes/sec)\n", GetBytesReceived(true), r / t / 1000000); double s = GetBytesSent(); printf(" bytes out: %lld (%f Mbytes/sec)\n", GetBytesSent(true), s / t / 1000000); printf("\n"); while (GetOutputLength() < 500000) { Send("zzzzzzzzzmmmmmmmmm1234lkkk54\r\n"); Send("zzzzzzzzzmmmmmmmmm1234lkkk543\r\n"); Send("zzzzzzzzzmmmmmmmmm1234lkkk54\r\n"); Send("zzzzzzzzzmmmmmmmmm1234lkkk543\r\n"); Send("zzzzzzzzzmmmmmmmmm1234lkkk54\r\n"); Send("zzzzzzzzzmmmmmmmmm1234lkkk543\r\n"); Send("zzzzzzzzzmmmmmmmmm1234lkkk54\r\n"); Send("zzzzzzzzzmmmmmmmmm1234lkkk543\r\n"); } // Send("\r\n"); }
void OnContent() { // std::cout << GetContentLength() << std::endl; gettime(&m_reply, NULL); { double treply = Diff(m_send, m_reply); // g_min_time2 = treply < g_min_time2 ? treply : g_min_time2; g_max_time2 = treply > g_max_time2 ? treply : g_max_time2; g_tot_time2 += treply; g_ant2 += 1; } gBytesIn += GetBytesReceived(true); gBytesOut += GetBytesSent(true); CreateNew(); }
void OnLine(const std::string& line) { gettime(&m_reply, NULL); m_b_active = true; { double treply = Diff(m_send, m_reply); // g_min_time2 = treply < g_min_time2 ? treply : g_min_time2; g_max_time2 = treply > g_max_time2 ? treply : g_max_time2; g_tot_time2 += treply; g_ant2 += 1; } // if (line != g_data) { fprintf(stderr, "\n%s\n%s\n", line.c_str(), g_data.c_str()); fprintf(stderr, "(reply did not match data - exiting)\n"); exit(-1); } // gBytesIn += GetBytesReceived(true); gBytesOut += GetBytesSent(true); if (m_b_one) { SetCloseAndDelete(); } else if (g_b_repeat && g_b_limit) { SendBlock(); } // add another if (!m_b_created && (!g_b_limit || !g_b_off) && !g_b_instant) { MySocket *p = new MySocket(Handler(), m_b_one); p -> SetDeleteByHandler(); p -> Open(gHost, gPort); Handler().Add(p); m_b_created = true; } }
void pSocket::ShowStatus(size_t max) { if (CTS()) { std::string client = "unknown"; std::string version = "-"; std::string id = GetPeer() -> GetID(); switch (id[0]) { case '-': if (id.substr(1,2) == "AZ") client = "Azureus"; if (id.substr(1,2) == "BB") client = "BitBuddy"; if (id.substr(1,2) == "CT") client = "CTorrent"; if (id.substr(1,2) == "MT") client = "MoonlightTorrent"; if (id.substr(1,2) == "LT") client = "libtorrent"; if (id.substr(1,2) == "BX") client = "Bittorrent X"; if (id.substr(1,2) == "TS") client = "Torrentstorm"; if (id.substr(1,2) == "TN") client = "TorrentDotNET"; if (id.substr(1,2) == "SS") client = "SwarmScope"; if (id.substr(1,2) == "XT") client = "XanTorrent"; if (id.substr(1,2) == "BS") client = "BTSlave"; if (id.substr(1,2) == "ZT") client = "ZipTorrent"; if (id.substr(1,2) == "AR") client = "Arctic"; if (id.substr(1,2) == "SB") client = "Swiftbit"; if (id.substr(1,2) == "++") client = "C++"; version = id.substr(3,4); break; case 'S': client = "Shadow"; version = id.substr(1,3); break; case 'U': client = "UPnP NAT Bit Torrent"; version = id.substr(1,3); break; case 'T': client = "BitTornado"; version = id.substr(1,3); break; case 'A': client = "ABC"; version = id.substr(1,3); break; case 'M': client = "Brams"; version = id.substr(1,7); break; case 'e': client = "BitComet"; break; } char up[100]; char dn[100]; if (GetBytesSent() / 1024 > 999) sprintf(up, "%4d MB", GetBytesSent() / (1024 * 1024)); else sprintf(up, "%4d kB", GetBytesSent() / 1024); if (GetBytesReceived() / 1024 > 999) sprintf(dn, "%4d MB", GetBytesReceived() / (1024 * 1024)); else sprintf(dn, "%4d kB", GetBytesReceived() / 1024); { std::string tmp; for (size_t i = 0; i < version.size(); i++) tmp += isprint(version[i]) ? version[i] : '.'; version = tmp; } } }