Re: GetAdapterInfo and Usage Count Increases

From: Adam Dyba [MS] (adyba_at_online.microsoft.com)
Date: 04/29/04


Date: Thu, 29 Apr 2004 14:34:29 -0700

GetAdaptersInfo is an IP helper API (IPHLPAPI) function which calls
WSAStartup because it uses some Winsock functions - this call will increment
the usage count. IPHLPAPI actually calls WSAStartup in more than one place,
and the usage count may increase up to 3.

Aside, any well behaved library or application using Winsock (1 or 2) should
call WSAStartup before calling any Winsock functions and call WSACleanup
before exiting. It is valid to call WSAStartup more than once as long as
there will be a corresponding WSACleanup call before library/application
unloads.

Adam

"troy anderson" <tander67@hotmail.com> wrote in message
news:%23R%23JtPeLEHA.3016@tk2msftngp13.phx.gbl...
> Why does the usage count on WinSock increase every time I invoke
> GetAdapterInfo but not for other WinSock APIs like send, recv, etc.?
>
> What happens when the Usage Count raps? Will WinSock unload if it wraps
to
> 0?
>
>



Relevant Pages

  • Re: GetAdapterInfo and Usage Count Increases
    ... WSAStartup because it uses some Winsock functions - this call will increment ... and the usage count may increase up to 3. ...
    (microsoft.public.windowsce.embedded.vc)
  • Re: GetAdapterInfo and Usage Count Increases
    ... WSAStartup because it uses some Winsock functions - this call will increment ... and the usage count may increase up to 3. ...
    (microsoft.public.windowsce.embedded)
  • Re: GetAdapterInfo and Usage Count Increases
    ... WSAStartup because it uses some Winsock functions - this call will increment ... and the usage count may increase up to 3. ...
    (microsoft.public.windowsce.app.development)
  • Re: WSAStartup, WSADATA, and class hierarchy
    ... "An application must call one WSACleanup call for every successful ... WSAStartup call to allow third-party DLLs to make use of a WS2_32.DLL on ... > it every time you need some Winsock facility. ... > multiple object files, multiple objects etc. but this is IMO just a ...
    (microsoft.public.vc.language)
  • Re: Unable to ping after device name changed Windows CE 6.0
    ... WSAStartup just initializes the WinSock library. ... SetHostName via a function pointer which according to the ... beitman AT applieddata DOT net ...
    (microsoft.public.windowsce.embedded)