本文整理汇总了C++中ThreadData::send方法的典型用法代码示例。如果您正苦于以下问题:C++ ThreadData::send方法的具体用法?C++ ThreadData::send怎么用?C++ ThreadData::send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ThreadData
的用法示例。
在下文中一共展示了ThreadData::send方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MSNServerThread
void __cdecl CMsnProto::MSNServerThread(void* arg)
{
ThreadData* info = (ThreadData*)arg;
if (info->mIsMainThread)
isConnectSuccess = false;
int tPortNumber = -1;
{
char* tPortDelim = strrchr(info->mServer, ':');
if (tPortDelim != NULL) {
*tPortDelim = '\0';
if ((tPortNumber = atoi(tPortDelim + 1)) == 0)
tPortNumber = -1;
else if (usingGateway && !(tPortNumber == 80 || tPortNumber == 443))
usingGateway = false;
}
}
if (usingGateway) {
if (info->mServer[0] == 0)
mir_strcpy(info->mServer, MSN_DEFAULT_LOGIN_SERVER);
else if (info->mIsMainThread)
mir_strcpy(info->mGatewayIP, info->mServer);
if (info->gatewayType)
mir_strcpy(info->mGatewayIP, info->mServer);
else {
if (info->mGatewayIP[0] == 0 && db_get_static(NULL, m_szModuleName, "GatewayServer", info->mGatewayIP, sizeof(info->mGatewayIP)))
mir_strcpy(info->mGatewayIP, MSN_DEFAULT_GATEWAY);
}
}
else {
if (info->mServer[0] == 0 && db_get_static(NULL, m_szModuleName, "DirectServer", info->mServer, sizeof(info->mServer)))
mir_strcpy(info->mServer, MSN_DEFAULT_LOGIN_SERVER);
}
NETLIBOPENCONNECTION tConn = { 0 };
tConn.cbSize = sizeof(tConn);
tConn.flags = NLOCF_V2;
tConn.timeout = 5;
if (usingGateway) {
tConn.flags |= NLOCF_HTTPGATEWAY;
tConn.szHost = info->mGatewayIP;
tConn.wPort = MSN_DEFAULT_GATEWAY_PORT;
}
else {
tConn.flags = NLOCF_SSL;
tConn.szHost = info->mServer;
tConn.wPort = MSN_DEFAULT_PORT;
}
if (tPortNumber != -1)
tConn.wPort = (WORD)tPortNumber;
debugLogA("Thread started: server='%s:%d', type=%d", tConn.szHost, tConn.wPort, info->mType);
info->s = (HANDLE)CallService(MS_NETLIB_OPENCONNECTION, (WPARAM)m_hNetlibUser, (LPARAM)&tConn);
if (info->s == NULL) {
debugLogA("Connection Failed (%d) server='%s:%d'", WSAGetLastError(), tConn.szHost, tConn.wPort);
switch (info->mType) {
case SERVER_NOTIFICATION:
goto LBL_Exit;
break;
case SERVER_SWITCHBOARD:
if (info->mCaller) msnNsThread->sendPacket("XFR", "SB");
break;
}
return;
}
if (usingGateway)
CallService(MS_NETLIB_SETPOLLINGTIMEOUT, WPARAM(info->s), info->mGatewayTimeout);
debugLogA("Connected with handle=%08X", info->s);
if (info->mType == SERVER_NOTIFICATION)
info->sendPacketPayload("CNT", "CON", "<connect>%s%s%s<ver>2</ver><agent><os>winnt</os><osVer>5.2</osVer><proc>x86</proc><lcid>en-us</lcid></agent></connect>\r\n",
*info->mState?"<xfr><state>":"", *info->mState?info->mState:"", *info->mState?"</state></xfr>":"");
else if (info->mType == SERVER_SWITCHBOARD) {
info->sendPacket(info->mCaller ? "USR" : "ANS", "%s;%s %s", MyOptions.szEmail, MyOptions.szMachineGuid, info->mCookie);
}
else if (info->mType == SERVER_FILETRANS && info->mCaller == 0) {
info->send("VER MSNFTP\r\n", 12);
}
if (info->mIsMainThread) {
msnNsThread = info;
}
debugLogA("Entering main recv loop");
info->mBytesInData = 0;
for (;;) {
int recvResult = info->recv(info->mData + info->mBytesInData, info->mDataSize - info->mBytesInData);
if (recvResult == SOCKET_ERROR) {
debugLogA("Connection %08p [%08X] was abortively closed", info->s, GetCurrentThreadId());
break;
}
//.........这里部分代码省略.........