Trapping the WSA_WOULDBLOCK error

How can I trap the WSA_WOULDBLOCK error and send any unsent data following that?

Date Entered: 10/9/2001    Last Updated: 06/14/2004

If the SetDataToSend() event cannot complete a transfer, it returns an error code. The code below is an easy way to handle this in the case of a WOULDBLOCK error.

int main (){
	IPDaemon ip;
	// Set up ip control, connection, etc

	while (ip.SetDataToSend(id, data, length) == 10035){ // WSAEWOULDBLOCK
		
		// wait for ReadyToSend event to fire, then continue, resending the last data sent minus the bytes successfully
		// sent, which you can determine from ip.GetBytesSent(id)
		
	}
}
Alternatively, you could use the Error Event to handle the error instead:
bool RETRY = false; // global variable
class myIpDaemon :: IPDaemon{
	virtual INT __stdcall FireError( USHORT &usErrorCode, LPSTR &lpszDescription ){
		if( usErrorCode == 10035){	// WSAEWOULDBLOCK
			RETRY = true;
		}
		else printf("Error: %i  -  %s.\n", usErrorCode, lpszDescription);	// for all other errors
	}
}

We appreciate your feedback.  If you have any questions, comments, or suggestions about this entry please contact our support team at kb@nsoftware.com.