Initializing and Cleaning Up
Windows socket implementations must be initialized before the socket API can be used by the Networking package and must be cleaned up when the application exits. The
RWWinSockInfo class simplifies these processes. Its constructor performs the initialization tasks and its destructor performs the termination tasks.
To use this class, declare an instance of
RWWinSockInfo in a scope that encloses all of the Networking package calls. Usually, instantiating one of these objects in the
main() or
WinMain() portion of your application is sufficient.
int main()
{
RWWinSockInfo sockApiInit; //1
...
} //2
or
int PASCAL WinMain(HINSTANCE, HANDLE, LPSTR, int)
{
RWWinSockInfo sockApiInit; //1
...
} //2
NOTE: If you use Windows and you plan to use any Networking package objects in a DLL, you must create a custom DLLMAIN() function, and you must create an instance of the RWWinsockInfo class in that function.