Identical Error Codes
Solution 1:
It appears Python is exposing the error code from the OS - the interpretation of the code is OS-dependent.
111 is ECONNREFUSED
on many Linux systems, and on Cygwin.
146 is ECONNREFUSED
on Solaris.
10061 is WSAECONNREFUSED
in winerror.h - it's the Windows Socket API's version of ECONNREFUSED
.
No doubt on other systems, it's different again.
The correct way to handle this is use symbolic comparisons based on the OS's definition of ECONNREFUSED
; that's the way you do it in C, for example. In other words, have a constant called ECONNREFUSED that has the value of ECONNREFUSED for that platform, in a platform-specific library (which will be necessary to link to the OS's socket primitives in any case), and compare error codes with the ECONNREFUSED constant, rather than magic numbers.
I don't know what Python's standard approach to OS error codes is. I suspect it's not terribly well thought out.
Post a Comment for "Identical Error Codes"