alpenguy
April 13th, 2004, 02:30 AM
What is wrong with this?
The client initiates contact with the server and sends a single CMsg object
When the Server receives it this happens :
A reply of 8 messages
void CServerDlg::dealWithRecvdMsg(CMsg& msg)
{
CMsg msg;
for ( int i = 0; i < 8; i++ )
{
// a different msg each time
SendPost(msg);
// watch what happens when the Sleep time changes
Sleep(1000);
}
}
on the other side
the client receives them :
void CCliSock::OnReceive(int nErrorCode)
{
CSocket::OnReceive(nErrorCode);
m_pParentdlg->PickUpPost(m_pArchiveIn);
}
the messages are deserialized :
void CClientDlg::PickUpPost(CArchive* pArchiveIn)
{
CMsg msg;
do
{
try
{
msg.Serialize(*pArchiveIn);
}
catch(CFileException e)
{
pArchiveIn->Abort();
AfxMessageBox(_T("Abort in CClientDlg.:PickupPost"));
}
if (pArchiveIn == NULL)
break;
} while (!pArchiveIn->IsBufferEmpty());
dealWithRecvdMsg(msg);
}
here the messages are taken apart and dealt with :
void CClientDlg::dealWithRecvdMsg(CMsg& msg)
{
// sort out the individual messages
}
If there is a 1000ms sleep time it works
if there is a 500ms sleep time it works
but it there is a 5ms sleep time between transmissions It Doesn't Work
and I only am able to see the 1st and 8th message.
What am I doing wrong?
The client initiates contact with the server and sends a single CMsg object
When the Server receives it this happens :
A reply of 8 messages
void CServerDlg::dealWithRecvdMsg(CMsg& msg)
{
CMsg msg;
for ( int i = 0; i < 8; i++ )
{
// a different msg each time
SendPost(msg);
// watch what happens when the Sleep time changes
Sleep(1000);
}
}
on the other side
the client receives them :
void CCliSock::OnReceive(int nErrorCode)
{
CSocket::OnReceive(nErrorCode);
m_pParentdlg->PickUpPost(m_pArchiveIn);
}
the messages are deserialized :
void CClientDlg::PickUpPost(CArchive* pArchiveIn)
{
CMsg msg;
do
{
try
{
msg.Serialize(*pArchiveIn);
}
catch(CFileException e)
{
pArchiveIn->Abort();
AfxMessageBox(_T("Abort in CClientDlg.:PickupPost"));
}
if (pArchiveIn == NULL)
break;
} while (!pArchiveIn->IsBufferEmpty());
dealWithRecvdMsg(msg);
}
here the messages are taken apart and dealt with :
void CClientDlg::dealWithRecvdMsg(CMsg& msg)
{
// sort out the individual messages
}
If there is a 1000ms sleep time it works
if there is a 500ms sleep time it works
but it there is a 5ms sleep time between transmissions It Doesn't Work
and I only am able to see the 1st and 8th message.
What am I doing wrong?