|
// TestClient.cpp: implementation of the CTestClient class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "SyncClient.h"
#include "TestClient.h"
#include "iostream"
using namespace std;
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CTestClient::CTestClient(SOCKET s, const char* pszPeerAddr, unsigned short nPeerPort, BOOL bCloseWait /* = TRUE */ )
: CSyncSocketWorker<CTestClient>(s, pszPeerAddr, nPeerPort, bCloseWait)
{
}
CTestClient::~CTestClient()
{
}
extern CRITICAL_SECTION g_cs;
void CTestClient::ProcessData()
{
const int nBufferSize = 8192;
char szBuffer[nBufferSize];
CFile file;
file.Open(TEXT("recv.jpg"), CFile::modeCreate | CFile::modeWrite);
int nRead;
DWORD dwStart = GetTickCount();
while(nRead = Read(szBuffer, nBufferSize))
{
file.Write(szBuffer, nRead);
if(IsShutingdown())
{
cout << "shuting down" << endl;
break;
}
}
cout << "Speed = " << double(file.GetLength()) / (double(GetTickCount() - dwStart) / 1000.0) / 1024 << "KB/s" << endl;
file.Close();
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.