📄 client.cpp
字号:
#include <stdafx.h>
#include "blocksocket.h"
#include "globle.h"
// clientsockthread.cpp (uses Winsock calls only)
UINT ClientThreadProc(LPVOID pParam)
{
// sends a blind request, followed by a request for a specific URL
CHttpBlockingSocket sClient;
char* buf = new char[100];
CSockAddr saServer, saPeer, saTest, saClient;
try {
sClient.Create();
//saServer = CBlockingSocket::GetHostByName(g_strIPServer, g_nPortServer);
saServer = CSockAddr(g_dwIPServer, g_nPortServer);
sClient.Connect(saServer);
sClient.GetSockAddr(saTest);
TRACE("SOCK CLIENT: GetSockAddr = %s, %d\n", saTest.DottedDecimal(), saTest.Port());
CString s;
s.Format("%d\r\n", g_side);
sClient.Write(s, s.GetLength(), 300);
// read all the server's response headers
for(;;)
{
if(g_side == RED_SIDE)
{
::WaitForSingleObject(g_eventStart, INFINITE);
sClient.Write(g_stringInfo, g_stringInfo.GetLength(), 300);
sClient.ReadHttpHeaderLine(buf, MAXLINELENGTH, 300);
::SendMessage((HWND) pParam, WM_START, (WPARAM) 0, (LPARAM) buf);
}
else
{
sClient.ReadHttpHeaderLine(buf, MAXLINELENGTH, 300);
::SendMessage((HWND) pParam, WM_START, (WPARAM) 0, (LPARAM) buf);
::WaitForSingleObject(g_eventStart, INFINITE);
sClient.Write(g_stringInfo, g_stringInfo.GetLength(), 300);
}
}
}
catch(CBlockingSocketException* e) {
LogBlockingSocketException(pParam, "CLIENT:", e);
e->Delete();
}
sClient.Close();
delete [] buf;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -