在CServer::OnReceive中的错误???在线等急 急 急谢谢
void CServer::OnReceive(int nErrorCode)
{
// TODO: Add your specialized code here and/or call the base class
char buff[10];
int bufflen=10;
CString ClientName;
int nLen = Receive(buff,bufflen);//接收
ClientName.Format(inet_ntoa(ClientAddr.sin_addr));//返回客户端的ip地址
if(buff[0]=='F')
{
CString str;
str="ok";
int len=str.GetLength();
m_pSock->Send(str,2,0);//就在这出的 问题????
}
CSocket::OnReceive(nErrorCode);
}
void CServer::OnAccept(int nErrorCode)
{
// TODO: Add your specialized code here and/or call the base class
CServer* pSocket=new CServer;
int iLen=sizeof(ClientAddr);
Accept(*pSocket,(LPSOCKADDR)&ClientAddr,&iLen);
m_pSock=pSocket;//不知道这样赋值对部队,我觉的这个地方有问题m_pSock是CServer的对象
//CSocket::OnAccept(nErrorCode);
}
/////CServer是由CSocket派生的
当程序执行到CServer::OnReceive里面的m_pSock->Send(str,2,0);
就出现错误:
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts
(Press Retry to debug the application)
终止(A) 重试(R) 忽略(I)
如果我把m_pSock->Send(str,2,0);放在void CServer::OnAccept里发送就没问题 ,不知道为啥,本人是个入门级的 呵呵 谢谢