Re: PATCH: Windows sockets

Kai Henningsen
2005-03-27T12:59:23Z

mark@codesourcery.com (Mark Mitchell) wrote on 26.03.05 in <42459E07.9020201@codesourcery.com>:

> > 6. Tweak safe_strerror to deal with Windows sockets error codes.
> >
> > I'm defenitely not thrilled by this tweak. You're only changing
> > "undocumented" into "winsock". I presume it helps with debugging this
> > stuff, but is it really worth the clutter it adds?
>
> I think so, yes. Windows strerror never returns NULL. For unknown
> values, it returns "Unknown error" with no indication of *which* unknown
> error. These errors are presented to users, so, if for example, a
> socket cannot be connected because the user entered the wrong port, or
> gdbserver is not running, the user would only see "Unknown error". I
> agree that, from a user-experience point of view, "winsock error 12345"
> is not all that helpful -- but at least there is *some* method for
> figuring out what went wrong.

Well ...

There *is* support in Win32 for getting error message text for OS error
numbers (which are completely different from errno numbers). There's a
slight complication in that until lately, these didn't cover Winsock
codes, but on modern Windows versions they do.

So it might make sense to try that.

See <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/
debug/base/retrieving_the_last_error_code.asp> for example code.

MfG Kai