接收空缓冲区

时间:2017-03-27 12:51:13

标签: c++ sockets mfc

我正在尝试与TCP-Modbus进行通信,但是当我在onAccept函数中发送跟踪时它没有任何内容,因为它没有任何东西,发送工作在调试器中工作,但是当我在接收时调试它未收到。

void CMisoc::OnAccept(int nErrorCode)
{
 unsigned char *ReceivedBuffer=new unsigned char[12];
 int len = this->Receive(ReceivedBuffer, 12);

 unsigned char *SendBuffer = new unsigned char[12];

 // Prepare answer with ModBus
 pDlg->MyModbus->ModBusReceived(ReceivedBuffer, SendBuffer, 1);

 // Answer
 pDlg->conected->Send(&SendBuffer[0], 12);

 delete[] SendBuffer;
 pDlg->conected->Close();

 Accept(*pDlg->conected);
 CSocket::OnAccept(nErrorCode);
}

0 个答案:

没有答案