Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Mar : Re: Socket Error # 0
| Subject: | Re: Socket Error # 0 |
| Posted by: | "Remy Lebeau (TeamB)" (no.spam@no.spam.com) |
| Date: | Thu, 22 Mar 2007 15:22:38 |
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:4602ffcb$1@newsgroups.borland.com...
> Your call stack is incomplete. TIdTCPConnection.WriteBuffer() does
> not directly call TIdStack.RaiseSocketError(). There where is all
of the
> calls in between for either TIdStack.CheckForSocketError() or
> TIdStack.RaiseSocketError()?
Ignore that. WriteBuffer() does directly call RaiseSocketError(), but
only if CheckForSocketError() returned True:
// Check to see if the error signifies disconnection
if GStack.CheckForSocketError(nByteCount, [ID_WSAESHUTDOWN,
Id_WSAECONNABORTED, Id_WSAECONNRESET]) then begin
DisconnectSocket;
GStack.RaiseSocketError(GStack.LastError);
end;
If Send() had returned SOCKET_ERROR, then only way that
CheckForSocketError() could return True is if WSAGetLastError()
returned WSAESHUTDOWN, WSAECONNABORTED, or WSAECONNRESET. Anything
else would result in a exception being thrown by CheckForSocketError()
instead of WriteBuffer(), and the ErrorCode would not be 0. Since
CheckForSocketError() is the only method that sets the
GStack.LastError property, what you describe suggests that
DisconnectSocket() is resetting the LastError back to 0 before
RaiseSocketError() is called, which is impossible as
DisconnectSocket() never calls CheckForSocketError().
On the other hand, WriteBuffer() does call CheckForDisconnect() before
calling CheckForSocketError(). Perhaps CheckForDisconnect() is
accessing the socket, indirectly resetting WSAGastLastError() back to
0. That would then cause CheckForSocketError() to throw an exception
with an ErrorCode of 0. But then, CheckForSocketError() should have
appeared in your call stack in that situation.
Gambit