dbgp
dbgp copied to clipboard
`DBGp_StartListening` does not give useful error information
In the event of an error in DBGp_StartListening it calls the closesocket dll func before checking the WinSocket error code. However, closesocket resets the error code so the information is lost.
DBGp_StartListening(localAddress="127.0.0.1", localPort=9000)
{
...
; An error occurred.
DllCall("ws2_32\closesocket", "ptr", s)
return DBGp_WSAE()
}
This prevents the library user from correctly reporting or attempting to resolve errors. For example, the following code should increment the port when the desired one is in use (perhaps by another debugger) but in the case of an error it goes directly to the exception with ErrorLevel of 0.
port := 9000
while (!DBGp_StartListening(, port))
{
if (ErrorLevel == "WSAE:10048") ; WSAEADDRINUSE
port++
else
throw Exception("Failed to start debugger",, ErrorLevel)
}