![]() |
InitializeSockets() |
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| Public Function |
Declared in: SpoofBase.h |
Declaration
static BOOL InitializeSockets(
BOOL bMultiThreaded=TRUE,
unsigned long ulNumberOfThreads=10);
DescriptionInitialize the sockets Using this method requires the application to have an active message map If a message map is not desired then use the method: InitializeSocketsNoMap bMultiThreaded - Do we want multithreaded support ulNumberOfThreads - Number of threads to allocate
Function Body
//To avoid double initialize
if (m_bInitialized)
{
//Report it
ReportStaticError(CSpoofBase_Class,"InitializeSockets","Already initialized!");
//Exit
return TRUE;
}
//Check that the number of threads are OK?
if (ulNumberOfThreads>CLibConfig::GetInstance().GetMaxThreads())
{
//Report it
ReportStaticError(CSpoofBase_Class,"InitializeSockets","Too many threads!");
//Exit
return FALSE;
}
//Do we have threads at all
if (bMultiThreaded &&
!ulNumberOfThreads)
{
//Report it
ReportStaticError(CSpoofBase_Class,"InitializeSockets","Didn't receive any threads!");
//Exit
return FALSE;
}
try
{
//Initialize the sockets
WORD wVersionRequested;
wVersionRequested=MAKEWORD(2,2);
//Try to initialize
WSADATA wsaData;
int iErr;
iErr=WSAStartup(wVersionRequested,
&wsaData);
//Did we succeed?
if (iErr!=0)
/* Tell the user that we could not find a usable */
/* WinSock DLL. */
return FALSE;
/* Confirm that the WinSock DLL supports 2.2.*/
/* Note that if the DLL supports versions greater */
/* than 2.2 in addition to 2.2, it will still return */
/* 2.2 in wVersion since that is the version we */
/* requested. */
if (LOBYTE(wsaData.wVersion)!=2 ||
HIBYTE(wsaData.wVersion)!=2)
{
/* Tell the user that we could not find a usable */
/* WinSock DLL. */
WSACleanup();
//Exit
return FALSE;
}
//Save the threading information
m_bMultiThreaded=bMultiThreaded;
m_ulNumberOfThreads=ulNumberOfThreads;
//Create the critical section
m_pCSection=COSManager::CreateCriticalSection();
//And we are initialized
m_bInitialized=TRUE;
return TRUE;
}
ERROR_HANDLER_STATIC_RETURN(CSpoofBase_Class,"InitializeSockets",FALSE)
See Also
This web site was generated
using Surveyor V4.50.811.1. Click
here
for more information. |
Site content copyright © 2003 Komodia LTD.. See the About page for additional notices. This page last updated: 24 Feb 2003. |