From: Jeff Johnson <jeff@jeffjohnson.net>
To: 'Bruce Momjian' <pgman@candle.pha.pa.us>
To: jeff@jeffjohnson.net
Cc: pgsql-interfaces@postgresql.org
Cc: pgsql-docs@postgresql.org
Subject: RE: [INTERFACES] libpq sockets on win32
Date: Mon, 4 Jun 2001 14:01:52 -0400
Message-ID: <B9C9130B5D27D4119D5D00A0C9D3A98710945E@SERVER> (raw)
In-Reply-To: <B9C9130B5D27D4119D5D00A0C9D3A987193173@SERVER>
> > This article describes the problem and work around.
> > http://msdn.microsoft.com/library/psdk/winsock/ovrvw3_26ia.htm
>
> I can't read that web site under Netscape.
>
> If I could read it, I think I could fix it. Please send it in some
> readable format.
>
I chopped the content out and stuck it into a basic HTML file and
attached it.
Thanks for taking a look,
Jeff
Attachments:errno.htm (text/html, 2.8K) download
<html><head></head><body>
<H3><A NAME="_win32_error_codes_errno_h_errno_and_wsagetlasterror_2"></A>Error Codes - errno, h_errno and WSAGetLastError</H3>
<P>Error codes set by Windows Sockets are <I>not</I> made available through the <I>errno</I> variable. Additionally, for the <B>getXbyY</B> class of functions, error codes are <I>not</I> made available through the <I>h_errno</I> variable. Instead, error codes are accessed by using the <A HREF="/library/psdk/winsock/wsapiref_2tiq.htm"><B>WSAGetLastError</B></A> function. This function is provided in Windows Sockets as a precursor (and eventually an alias) for the Win32 function <A HREF="/library/psdk/winbase/errors_3uwi.htm"><B>GetLastError</B></A>. This is intended to provide a reliable way for a thread in a multithreaded process to obtain per-thread error information.</P>
<P>For compatibility with BSD, an application may choose to include a line of the form:</P>
<PRE>#define errno WSAGetLastError</PRE>
<P>This allows networking code which was written to use the global <I>errno</I> to work correctly in a single-threaded environment. There are, obviously, some drawbacks. If a source file includes code which inspects <I>errno</I> for both socket and nonsocket functions, this mechanism cannot be used. Furthermore, it is not possible for an application to assign a new value to <I>errno</I>. (In Windows Sockets the function <A HREF="/library/psdk/winsock/wsapiref_7a42.htm"><B>WSASetLastError</B></A> may be used for this purpose.)</P>
<P><B>TYPICAL BSD STYLE</B></P>
<PRE>r = recv(...);
if (r == -1
&& errno == EWOULDBLOCK)
{...}</PRE>
<P><B>PREFERRED STYLE</B></P>
<PRE>r = recv(...);
if (r == -1 /* (but see below) */
&& WSAGetLastError == EWOULDBLOCK)
{...}</PRE>
<P>Although error constants consistent with Berkeley Sockets 4.3 are provided for compatibility purposes, applications should, where possible, use the WSA error code definitions. This is because error codes returned by certain Windows Sockets routines fall into the standard range of error codes as defined by Microsoft® C®. Thus, a better version of the preceding source code fragment is:</P>
<PRE>r = recv(...);
if (r == -1 /* (but see below) */
&& WSAGetLastError == WSAEWOULDBLOCK)
{...}</PRE>
<P>This specification defines a recommended set of error codes, and lists the possible errors that can be returned as a result of each function. It may be the case in some implementations that other Windows Sockets error codes are returned in addition to those listed, and applications should be prepared to handle errors other than those enumerated under each function description. However Windows Sockets does not return any value that is not enumerated in the table of legal Windows Sockets errors given in the section <A HREF="/library/psdk/winsock/errors_3wc2.htm">Error Codes</A>.</P>
</body>
</html>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-docs@postgresql.org
Cc: jeff@jeffjohnson.net, pgman@candle.pha.pa.us, pgsql-interfaces@postgresql.org
Subject: Re: [INTERFACES] libpq sockets on win32
In-Reply-To: <B9C9130B5D27D4119D5D00A0C9D3A98710945E@SERVER>
References: <B9C9130B5D27D4119D5D00A0C9D3A987193173@SERVER> <B9C9130B5D27D4119D5D00A0C9D3A98710945E@SERVER>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox