leafarsetnofis
asked on
How to handle 10054 socket error?
I need to handle the socket error 10054 (Conection reset by peer). I'm using try/except but when the exception raised is impossible to reconnect the socket, the only way to reconnet with server is closing the application and start again.
Anybody know how to handle this exception withou restarting the application in order to reconnect to server when the app raise the exception?
Anybody know how to handle this exception withou restarting the application in order to reconnect to server when the app raise the exception?
In your exception-handler, ensure the socket is closed and then re-connect it. You should not need to restart the app!
ASKER
Ok, Ciuly, I tried your tip, indy raise exception...but its the same: can't reconnect to the server...
kenpem: I'm not sure how to verify if the socket is closed or not... I tried with:
If IdTCPClient1.Socket.Connec ted then....
but the app raise the same exception: 10054 ..etc...
I closed the connection in code when the exception occur (is a dial up connection) an then reconnect to the ISP and the socket reconect ok (Without restart the app!) . But I don't think it's the best way to handle this exception.
Can you explain me how to verify if the socket is closed withou raise the exception?
Thanks to all.
kenpem: I'm not sure how to verify if the socket is closed or not... I tried with:
If IdTCPClient1.Socket.Connec
but the app raise the same exception: 10054 ..etc...
I closed the connection in code when the exception occur (is a dial up connection) an then reconnect to the ISP and the socket reconect ok (Without restart the app!) . But I don't think it's the best way to handle this exception.
Can you explain me how to verify if the socket is closed withou raise the exception?
Thanks to all.
Hi,
If it can help, see eventually there and http://www.indyproject.org/KB/:
http://www.sockets.com/err_lst1.htm#WSAECONNRESET (the reason of error)
and
http://www.sockets.com/err_lst1.htm#WSAECONNABORTED for cheks to perform.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
did you write the "server" you are connecting to?
so do womething like this:
try
blabla with indy
except
on e:EIdException do
raise e;
on e:exception do
do whatever with other exceptions.
end;