다음을 통해 공유


AfxSocketInit

Call this function in your CWinApp::InitInstance override to initialize Windows Sockets.

BOOL AfxSocketInit( 
   WSADATA* lpwsaData = NULL  
);

매개 변수

  • lpwsaData
    A pointer to a WSADATA structure. If lpwsaData is not equal to NULL, then the address of the WSADATA structure is filled by the call to WSAStartup. This function also ensures that WSACleanup is called for you before the application terminates.

반환 값

Nonzero if the function is successful; otherwise 0.

설명

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.

코드

if (!AfxSocketInit())
{
   AfxMessageBox(_T("Failed to Initialize Sockets"), MB_OK | MB_ICONSTOP);
   return FALSE;
}

요구 사항

Header: afxsock.h

참고 항목

참조

CWinApp::InitInstance

개념

MFC 매크로 및 전역