Click to See Complete Forum and Search --> : Question about MFC socket programing, pleassse help


shahin
January 6th, 2005, 05:05 PM
I have a simple client and server application which is writen in MFC. My server outputs data in TCPIP mode and this is my write function:
unsigned int CClientSock::Write( const unsigned char* Buffer, const unsigned long numBytes, const unsigned short TxID, const unsigned int timesToIssue, const unsigned int delayInMilliseconds)
{
int iNumBytes = numBytes;

if(Send(Buffer, numBytes) == SOCKET_ERROR)
{
NError::WarningMessage(NInternetComm::GetErrorEntry(GetLastError()));


iNumBytes = -1;
}
return iNumBytes;
}

and in my client I do a recive. very simple, I know :(
My problem is that, in my client sometimes, I need to run in debug mode ( visual C++) and have a break point. In this condition, my server keeps on sending data and after a while, it hangs on send(buffer,... function.

I thought, since this is TCPIP and my reciver needs to send acknowledgement back, then the first time server tries to send something,( after I encountered a break point in my client) then send should get an error. But it is not getting it.

I am sooo confuse, I know this is stupid question and you wonder why I need to do this and why shouldn't I debug in any other method.

But I am doing this for someone and they want to do it this way. So is there a work around ?? Or is this way of debuging even possibel??
Anyway, help is greatly apperitiated.

m-streeter
January 7th, 2005, 06:17 AM
My problem is that, in my client sometimes, I need to run in debug mode ( visual C++) and have a break point. In this condition, my server keeps on sending data and after a while, it hangs on send(buffer,... function.

I thought, since this is TCPIP and my reciver needs to send acknowledgement back, then the first time server tries to send something,( after I encountered a break point in my client) then send should get an error. But it is not getting it.

This is not my understanding of how things work with TCP/IP. Flow control is not implemented using acknowlegements from the reciever. Two-way communication is asynchronous. Flow control is handled using a (variable-sized) sliding window, so your sender will keep on transmitting until the window is full. Worse, even if you make the window smaller (defined in he TCP header) you may still get retransmissions of unacknowledged packets from the sender. Check out TCP/IP description in a computer networks book.

One thing you could do is terminate the connection when your debugging condition arises (needs code rather than a breakpoint in a debugger). Perhaps you can find a solution at the IP level. HTH.