Page 1 of 1

TScSSHClient.Connect WSAGetLastError overwritten to 0

Posted: Tue 08 Nov 2011 12:47
by Memnarch
Hi,
Just noticed if i receive an exception in

MyClient.Connect()

int prints the WSAGetLastError number into the exception message. Calling WSAGetLastError inside the exceptionblock however returns 0. It seems that it has been overwritten within the Connect function.

i would prefer to use WSAGetLastError for receiving detailed info at runtime for my own exception handling.

Greetings
Memnarch

Posted: Fri 11 Nov 2011 13:16
by Dimon
The last error code is cleared by the CloseSocket procedure that is called in the case of wrong connection.
SecureBridge returns an exception with the exact error code and you can read about this error in details on MSDN.

Posted: Sun 13 Nov 2011 14:59
by Memnarch
Shure, i can read about it in the MSDN but i cannot react to it at runtime easily. If its overriden by the close socket function, maybe extending the exception with an error code?

Because based on the errorcode i want to log some things and/or give feedback to the user, which isnt possible at this time(parsing the exception message does not seem to be a good idea)


Greets
Memnarch

Posted: Wed 16 Nov 2011 07:20
by Dimon
Thank you for the advice. We will investigate the possibility of adding such functionality in one of the next SecureBridge builds.

Posted: Mon 16 Jan 2012 12:00
by Dimon
Begining from SecureBridge version 4.1.2 you can know the error code returned by WSAGetLastError by handling the SocketException exception using the SocketException.ErrorCode property.