A
A
AXCHG2019-06-03 10:23:59
C++ / C#
AXCHG, 2019-06-03 10:23:59

Can there be problems when calling WSAStartup() multiple times?

Hello!
There is a Win32 application. It loads several Win32 DLLs and calls some initialization function from each. The DLL libraries most likely do not know about the existence of each other, and each calls WSAStartup () in its initialization function.
DLL libraries are written in such a way that they do not always check what is returned in the structure with information from WSAStartup (). (only the return value is checked).
Question. What problems can be associated with this? In case, for example, two different DLLs call WSAStartup() with different versions? (Though, versions prior to 2.0 are not exactly requested.)
How to write an application? If it is necessary to use three or five third-party DLLs, about which we "know nothing", and the application itself must also use Windows Sockets?
(it is assumed that tricks like intercepting calls to win sock dll are not used, and we cannot influence how libraries are initialized)
(in case only the DLL from the whole process works with the network (and accordingly, WSAStartup () is called only once) - everything definitely works correctly).
Thank you very much in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2019-06-03
@axchg

There won't be any problems. From documentation :
It is only necessary to WSACleanupcall then as many times as it was calledWSAStartup

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question