Article View: borland.public.cppbuilder.internet.socket
Article #2295Re: BDS2006 requires WSAStartup be called...
From: Remy Lebeau (TeamB)
Date: Wed, 07 Jun 2006 17:37
Date: Wed, 07 Jun 2006 17:37
49 lines
3398 bytes
3398 bytes
"Mark Jacobs" <http://www.jacobsm.com/mjmsg?Borland%20Newsgroup> wrote in message news:4486930a@newsgroups.borland.com... > What other functions would I have to use in order to require WSAStartup? All of the socket-related functions require WSAStartup(). It initializes the calling thread to use the socket library. For example, one thing it does is to create the TLS slot (thread local storage) that WSAGetLastError() uses to store error codes. That is why WSAGetLastError() can't be used until after WSAStartup() returns a successful return value. If WSAStartup() fails, there is no guarantee that the TLS has been created. > What 3rd party VCL components use windows sockets? There are too many to list. There are large libraries, such as Indy, ICS, and Synapse. But there are numerous other component implementations that use sockets for other, more specialized, purposes. That is like asking "what third-party components use TWinControl". > If there is a 3rd party library calling WSAStartup automatically We've already covered that. The code you showed earlier is including an ICS header file. So ICS is the one calling WSAStartup() for its own purposes. > how can I identify which one it is? There is no straight-forward way to do that. Nor should you try to care about it. As I already told you earlier, just call WSAStartup() in your own code regardless of what the rest of the project is doing. It is perfectly safe to call WSAStartup() multiple times. Like any other API, WinSock is implemented as a DLL. Calling WSAStartup() multiple times will only load the DLL once the first time, and then increment its reference count on subsequent calls. Just make sure that you call WSACleanup() once for each successful WSAStartup() so that the reference count is balanced, otherwise the DLL will not be unloaded properly. > If WSAStartup has been called multiple times, how do oyu > know how many times to call WSACleanup? You have to call WSACleanup() once, and only once, for each successful call to WSAStartup() that you make. If you call WSAStartup() in your own code once, and it succeeds, then call WSACleanup() only once in your own code. Every other library/component that also calls WSAStartup() will be doing the same thing. You DO NOT call WSACleanup() in your own code for other people's calls to WSAStartup(). Gambit
Technical Details
Message-ID:
<44870f43$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<44855a92$1@newsgroups.borland.com> <4485b07c$1@newsgroups.borland.com> <4486930a@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 11508e,ef067702696d334e X-Google-Attributes: gid11508e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.internet.socket References: <44855a92$1@newsgroups.borland.com> <4485b07c$1@newsgroups.borland.com> <4486930a@newsgroups.borland.com> Subject: Re: BDS2006 requires WSAStartup be called... Date: Wed, 7 Jun 2006 10:37:38 -0700 Lines: 51 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <44870f43$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1149701955 68.69.17.41 (7 Jun 2006 10:39:15 -0700) Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail