Mark- 31 Posted Wednesday at 11:36 PM Hello, Delphi 10.2.3, (VCL) current version of ICS (V9.4). Testing to verify I caught and handled the issue of the customer entering a bad IP address for binding. The IP address is formatted correctly, just not a valid IP address for any present interface. I was using the OnError callback. Call connect, onError is called but, "LastError" was zero. Switched to catching it as an exception try Connect except end; LastError is still zero. Looked in the source at procedure TCustomWSocket.BindSocket; ... if WSocket_Synchronized_bind(HSocket, PSockAddrIn(@LocalSockName)^, SockNamelen) <> 0 then begin and the correct error code 10049 (WSAEADDRNOTAVAIL) is present but, it is never assigned to LastError, that I could see. Perhaps there is something different I should be doing. Any ideas? Thanks, Mark Share this post Link to post
Remy Lebeau 1572 Posted Thursday at 01:24 AM 1 hour ago, Mark- said: I was using the OnError callback. Call connect, onError is called but, "LastError" was zero. Have you tried calling WSAGetLastError() directly? At the point where OnError is called, the last socket error code might not have been overwritten yet. 1 hour ago, Mark- said: Switched to catching it as an exception try Connect except end; LastError is still zero. The error code is stored in the raised ESocketException in its ErrorCode property. 1 hour ago, Mark- said: Looked in the source at procedure TCustomWSocket.BindSocket; ... if WSocket_Synchronized_bind(HSocket, PSockAddrIn(@LocalSockName)^, SockNamelen) <> 0 then begin and the correct error code 10049 (WSAEADDRNOTAVAIL) is present but, it is never assigned to LastError, that I could see. Sounds like a bug that should be reported to the ICS author. 1 Share this post Link to post
Mark- 31 Posted Thursday at 01:51 AM 22 minutes ago, Remy Lebeau said: The error code is stored in the raised ESocketException in its ErrorCode property. Sounds like a bug that should be reported to the ICS author. Thank you Remy. This: WsocketErrorDesc(ESocketException(exceptObject).ErrorCode) works. I am hoping Angus reads the post. Share this post Link to post
Remy Lebeau 1572 Posted Thursday at 05:11 AM 3 hours ago, Mark- said: This: WsocketErrorDesc(ESocketException(exceptObject).ErrorCode) works. I don't think you need to call WsocketErrorDesc() as ESocketException also has an ErrorMessage property. Share this post Link to post
Mark- 31 Posted Thursday at 11:34 AM (edited) 6 hours ago, Remy Lebeau said: I don't think you need to call WsocketErrorDesc() as ESocketException also has an ErrorMessage property. You are correct, thank you. Edited Thursday at 11:38 AM by Mark- Share this post Link to post