Solution:
Add the following code to the constructor of the subclass that inherits the CAsyncSocket class:
1 if (!AfxSocketInit()) 2 AfxMessageBox(IDP_SOCKETS_INIT_FAILED);
In addition, select "Windows Sockets" when creating the dialog item , otherwise IDP_SOCKETS_INIT_FAILED will report an error.
If the C***App class inherits the CAsyncSocket class, add the above code to the initialization function InitInstance() .