Home > Back-end >  0 xc0000005: read position 0 x... When access conflict
0 xc0000005: read position 0 x... When access conflict

Time:09-30

CClientSocket * m_WebSock=NULL;
_EachOtherData eoData;
//global variable

Void ProcessPendingReceive (CClientSocket * pSocket)//data over automatic call
{
ExplanData (pSocket, (char *) MSG. M_strText, MSG, len);//the data processing function
}
Void ExplanData (CClientSocket * pSocket, char * strTmp, int strLen)
{
If (strLen & lt;=0)
return;
If (* strTmp==cHD & amp; &
* (strTmp + 1)==cHD)//"# #" is for Web server-side data
{
ExplanWeb (pSocket, pStr + sID. GetLength () + strlen (pID) + 2 + 1);//parse Web server-side data
EoData. PWebSocket=pSocket;//save WebSock
}
If (* strTmp=='R')//R
{
EoData. PSocket=pSocket;
EoData. PStr=strTmp;
EoData. Len=strLen;
CWinThread * pRobotThread=AfxBeginThread (RobotProc, & amp; EoData);
PRobotThread - & gt; ResumeThread ();
}
}
Void ExplanWeb (CClientSocket * pSocket, char * pStr)
{
int i=0;
M_WebSock=pSocket;//get the WebSocket
Cstrings sHost=GetNameValue (pStr, pHost);
Int iCom=atoi (sCom);
The switch (iCom)
{
Case ALL_DEV:
SendWebMsg (m_WebSock, ALL_DEV, sHost, 0);
break;
}
}
Void SendWebMsg (CClientSocket * pSocket, int iCom, cstrings sHost, int iDevID)
{
If (pSocket!=NULL)
{
Cstrings strTmp="";
Cstrings STR="";
Char * pStr=NULL;
Int cpLen=0;
If (iCom==ALL_DEV)
{
If (pStr!=NULL)
{
PSocket - & gt; Send (pStr, cpLen);
}

}
}
UINT RobotProc (LPVOID lpParam)
{
LpParam _EachOtherData * pData=https://bbs.csdn.net/topics/(_EachOtherData *);
LpParam CServerDlg * pDlg=(CServerDlg *);
STR=pDlg - & gt; GetDataToRobot (pData - & gt; PSocket, pData - & gt; PStr, pData - & gt; Len);
PData - & gt; PSocket - & gt; WriteMsg (STR) GetBuffer (), strlen (STR));
return 0;
}
Cstrings GetDataToRobot (CClientSocket * the sock, char * pStr, int len)
{
Cstrings tempStr="";
Cstrings rtnStr="";

EoData. PSocket=sock;
EoData. PStr=pStr;
EoData. Len=strlen (pStr);
PRobotResponseThread=AfxBeginThread (RobotResponseProc, & amp; EoData);//machine response
PRobotResponseThread - & gt; ResumeThread ();
//Sleep (1000);
return 0;
}
UINT RobotResponseProc (LPVOID lpParam)
{
LpParam _EachOtherData * pData=https://bbs.csdn.net/topics/(_EachOtherData *);
Cstrings temp=pData - & gt; PStr;
Int first and last;
The first=temp. Find (" R ");
The last=temp. Find (";" );
Cstrings STR=temp. Mid (first, last).
Char * pStr=STR. GetBuffer (0);
Int len=strlen (pStr);
M_WebSock=pData - & gt; PWebSocket;
If (m_WebSock!=NULL)
M_WebSock - & gt; Send (pStr, len);
}

CodePudding user response:

Off the antivirus software may be right
  • Related