Visual Studio 2010 - Visual C++
AfxSocketInit
Call this function in your CWinApp::InitInstance override to initialize Windows Sockets.
BOOL AfxSocketInit( WSADATA* lpwsaData = NULL );
Parameters
Return Value
Nonzero if the function is successful; otherwise 0.
Remarks
When using MFC sockets in secondary threads in a statically linked MFC application, you must call AfxSocketInit in each thread that uses sockets to initialize the socket libraries. By default, AfxSocketInit is called only in the primary thread.
Code
Visual C++
if (!AfxSocketInit()) { AfxMessageBox(_T("Failed to Initialize Sockets"), MB_OK | MB_ICONSTOP); return FALSE; }
Requirements
Header: afxsock.h
See Also