Skip to Content.
Sympa Menu

freetds - Re: [freetds] WSAEnumProtocols call

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddy77 AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] WSAEnumProtocols call
  • Date: Wed, 11 Feb 2009 15:45:04 +0100

2009/2/11 James K. Lowden <jklowden AT freetds.org>:
> Frediano Ziglio wrote:
>> I don't understand why we call WSAEnumProtocols in
>> winsock_initialized. I never used this function but I can guarantee
>> that WSAStartup is sufficient.
>
> I was looking for a safe way to answer this question: Has winsock been
> initialized?
>
> I'm not sure what the effect is of calling WSAStartup twice. There isn't
> any documented error from WSAStartup that means, "hey, dummy, you already
> called WSAStartup and I'm initialized already!".
>
> I thought it was safer to call WSAEnumProtocols to discover if winsock is
> not initialized. It must be cheap; it's only returning its configuration
> data. And it returns a very clear answer as to whether or not winsock is
> working.
>

Oh... no, you can initialize with WSAStartup as many time you want.
Personally I never call WSACleanup and usually I call WSAStartup in
main (or similar). A variable winsock_initialized (true/false) is
usually sufficient. I realize it cause trying to cross compile FreeTDS
linker didn't find WSAEnumProtocols (in ws2_32 but not in wsock32...
perhaps I should link directly to ws2_32, wsock32 is ancien).

freddy77




Archive powered by MHonArc 2.6.24.

Top of Page