Hi,
I am using the CSocketFile class along with CArchive. The problem that I am having is that messages are being sent to me (I checked with Ethereal about this), but I am apparently not picking up some messages. For example, I'll get the first message sent to me, but not any subsequent messages. I've seen topics on other boards about this scenario, and their solution is to do only one read, which isn't applicable in my scenario, because I want to first read in a header that has the message length, and based on that read more data. The header and data are sent as one packet, like a TCP packet. I have a onReceive function:
Code:
void A::OnReceive(int nErrorCode) // A is derived from CSocket
{
// TODO: Add your specialized code here and/or call the base class
ReadMessage(ar_read);
}
And here is my ReadMessage code:
Code:
void B::ReadMessage(CArchive &ar)
{
uchar header[4];
uchar buf[100]
if(!ar.IsLoading())
{
ar.Read(header, 4);
ar.Read(buf, header[1]); // header[1] is the length
}
}
My program isn't crashing. Any idea why my messages are not being picked up?
Thanks.