Net::send error
by CdnGater · in Torque Game Engine · 06/05/2007 (8:03 am) · 0 replies
I found an error in the core of the send process for the Win32 process. I also found no reference to this in the forums. I double checked and the return value from the send is not used for the TCPObject, but neverless, this is an error.
The following is from the Microsoft help for ::send msdn2.microsoft.com/en-us/library/xxbked11(VS.80).aspx
Now examine the existing code snippet below
As you can see from the description, ::send will return a value > 0 if the send was successful. But the code will think its an error and call getLastError(). getLastError() will return Net::UnknownError.
I propose the following change
This way the send function does not return an error on a successful send, and will return an error only on a blocking or other error.
The following is from the Microsoft help for ::send msdn2.microsoft.com/en-us/library/xxbked11(VS.80).aspx
Quote:
If no error occurs, Send returns the total number of characters sent. (Note that this can be less than the number indicated by nBufLen.) Otherwise, a value of SOCKET_ERROR is returned, and a specific error code can be retrieved by calling GetLastError.
Now examine the existing code snippet below
Net::Error Net::send(NetSocket socket, const U8 *buffer, S32 bufferSize)
{
S32 error = ::send(socket, (const char*)buffer, bufferSize, 0);
if(!error)
return NoError;
return getLastError();
}As you can see from the description, ::send will return a value > 0 if the send was successful. But the code will think its an error and call getLastError(). getLastError() will return Net::UnknownError.
I propose the following change
Net::Error Net::send(NetSocket socket, const U8 *buffer, S32 bufferSize)
{
S32 error = ::send(socket, (const char*)buffer, bufferSize, 0);
if(error == SOCKET_ERROR)
return getLastError();
return NoError;
}This way the send function does not return an error on a successful send, and will return an error only on a blocking or other error.