问题
I have noticed that I receive an EIdSocketError with LastError = 10054 or 10053 when the device I'm talking to sends a RESET response. Which makes sense, given 10054 is Connection Reset By Peer.
So is there anything I can check in Indy to determine if this has ocurred rather than wrapping my code in try/except block and looking for 10054 or 10053 error codes?
One scenario I encountered was the modem replied with a RESET reply after I connected (Indy didn't raise an exception) so from my point of view the connection succeeded. I then attempted to write to the socket (ie send a packet using TidTCPClient) and the 10054 error was raised.
Is it possible to see this RESET reply at all?
Thanks
回答1:
Using try..except
is the right way. Indy communicates throught exceptions. Even 'Connection closed gracefully' is an exception in Indy's eyes.
来源:https://stackoverflow.com/questions/9800165/indy-know-when-modem-has-sent-a-reset-rst-flag