RE: [INTERFACES] Win32 interface

From: Magnus Hagander <mha(at)sollentuna(dot)net>
To: "'Tom Lane'" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Hiroshi Inoue <Inoue(at)tpf(dot)co(dot)jp>
Cc: "'David Giffin'" <david(at)agent911(dot)com>, "Ken J(dot) Wright" <ken(at)ori-ind(dot)com>, pgsql-interfaces(at)postgreSQL(dot)org
Subject: RE: [INTERFACES] Win32 interface
Date: 1999-09-06 15:01:05
Message-ID: 215896B6B5E1CF11BC5600805FFEA82101F71092@sirius.edu.sollentuna.se
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

> >> ISTM there was some reason it wouldn't work, like maybe you can
> >> only call WSAStartup once per program, but I don't recall for sure.
>
> > We can call WSAStartup() more than once. However,there must be a
> > call to WSACleanup() for every successful call to WSAStartup()
> > made by a task. Only the final WSACleanup() for that task does the
> > actual cleanup.
> >
> > The simplest way may be to call WSAStartup() while connecting and
> > to call WSACleanup() while finishing(including error cases).
>
> That would be an easy change. Are these functions fast enough that
> calling them for every connect/disconnect cycle would be tolerable?

I beleive so. But we could probably get away from that using static
variables, no? Somewhere just put:

static int has_wsastartup = 0;

...

if (!has_wsastartup) {
has_wsastartup = 1;
WSAStartup()...
}

That way, it would only be run once, right?
Naturally, everything within #ifdef WIN32.

One could also check the result code from the first winsock call. If that
one is 'Winsock not initialized', then initialize it and try again. This
would get us around the case of the client application calling WSAStartup()
on its own. But that is probably not necessary - that applcation will call
WSACleanup itself, and an app is allowed to call WSAStartup() more than
once.

Mvh,
Magnus

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Mark Dzmura 1999-09-06 16:02:06 JDBC Documentation??
Previous Message Tom Lane 1999-09-06 14:54:47 Re: [INTERFACES] Win32 interface