本文整理汇总了C++中CClientSocket::GetLastError方法的典型用法代码示例。如果您正苦于以下问题:C++ CClientSocket::GetLastError方法的具体用法?C++ CClientSocket::GetLastError怎么用?C++ CClientSocket::GetLastError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CClientSocket
的用法示例。
在下文中一共展示了CClientSocket::GetLastError方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnBnClickedStart
void CClientDlg::OnBnClickedStart()
{
CString strAddress;
CString strPort;
CString strTestTimes;
CString strTestInterv;
CString strThreadCount;
CString strThreadInterv;
CString strDataLen;
m_Address.GetWindowText(strAddress);
m_Port.GetWindowText(strPort);
m_TestTimes.GetWindowText(strTestTimes);
m_TestInterv.GetWindowText(strTestInterv);
m_ThreadCount.GetWindowText(strThreadCount);
m_ThreadInterv.GetWindowText(strThreadInterv);
m_DataLen.GetWindowText(strDataLen);
m_strAddress = strAddress.Trim();
m_usPort = (USHORT)_ttoi(strPort);
m_iTestTimes = _ttoi(strTestTimes);
m_iTestInterv = _ttoi(strTestInterv);
m_iThreadCount = _ttoi(strThreadCount);
m_iThreadInterv = _ttoi(strThreadInterv);
m_iDataLen = _ttoi(strDataLen);
if(!CheckParams())
return;
SetAppState(ST_STARTING);
m_dwBeginTickCount = 0;
m_dwEndTickCount = 0;
m_dwTimeconsuming = 0;
m_llTotalReceived = 0;
m_llTotalSent = 0;
m_llExpectReceived = (LONGLONG)m_iTestTimes * (LONGLONG)m_iThreadCount * (LONGLONG)m_iDataLen;
m_vtClients.Clear();
m_sendBuffer.Malloc(m_iDataLen, true);
for(int i = 0; i < m_iThreadCount; i++)
{
smart_simple_ptr<CClientSocket> pSocket = new CClientSocket(this);
if(pSocket->Start(m_strAddress, m_usPort))
m_vtClients->push_back(pSocket.release());
else
{
::LogClientStartFail(pSocket->GetLastError(), pSocket->GetLastErrorDesc());
m_vtClients.Clear();
m_sendBuffer.Free();
SetAppState(ST_STOPED);
return;
}
}
::LogClientStart(m_strAddress, m_usPort);
DWORD dwSendDelay = 3;
CString strMsg;
strMsg.Format(_T(" *** willing to send data after %d seconds ..."), dwSendDelay);
::LogMsg(strMsg);
::WaitWithMessageLoop(dwSendDelay * 1000);
SetAppState(ST_STARTED);
m_dwBeginTickCount = ::GetTickCount();
BOOL bTerminated = FALSE;
for(int i = 0; !bTerminated && i < m_iTestTimes; i++)
{
for(int j = 0; !bTerminated && j < m_iThreadCount; j++)
{
CClientSocket* pSocket = m_vtClients[j];
if(!pSocket->Send(pSocket->GetConnectionID(), m_sendBuffer, (int)m_sendBuffer.Size()))
{
::LogClientSendFail(i + 1, j + 1, pSocket->GetLastError(), pSocket->GetLastErrorDesc());
bTerminated = TRUE;
break;
}
if(m_iThreadInterv > 0 && j + 1 < m_iThreadCount)
::WaitWithMessageLoop(m_iThreadInterv);
}
if(m_iTestInterv > 0 && i + 1 < m_iTestTimes)
::WaitWithMessageLoop(m_iTestInterv);
}
}