CSocket::Create()是建立了一个socket,估计调用的是API函数socket() 下面是他的错误码 Error code Meaning WSANOTINITIALISED A successful WSAStartup call must occur before using this function. WSAENETDOWN The network subsystem or the associated service provider has failed. WSAEAFNOSUPPORT The specified address family is not supported. WSAEINPROGRESS A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function. WSAEMFILE No more socket descriptors are available. WSAENOBUFS No buffer space is available. The socket cannot be created. WSAEPROTONOSUPPORT The specified protocol is not supported. WSAEPROTOTYPE The specified protocol is the wrong type for this socket. WSAESOCKTNOSUPPORT The specified socket type is not supported in this address family. 建议楼主看MSDN好了!
在initinstance里需要调用afxinitsocket();
create创建一个socket对象
2.在CxxApp的initinstance()里需要调用
afxinitsocket();
代码如下:
BOOL CTestModuleApp::InitInstance()
{
//Update by Daniel Zhu
if (!AfxSocketInit())
{
AfxMessageBox(_T("Windows 通信端口初始化失败"));
return FALSE;
}
//AfxMessageBox("Windows 通信端口初始化成功");
return CWinApp::InitInstance();
}
你按照alphapiao(奉旨灌水钦差)的方法就可以解决
下面是他的错误码
Error code Meaning
WSANOTINITIALISED A successful WSAStartup call must occur before using this function.
WSAENETDOWN The network subsystem or the associated service provider has failed.
WSAEAFNOSUPPORT The specified address family is not supported.
WSAEINPROGRESS A blocking Windows Sockets 1.1 call is in progress, or the service provider is still processing a callback function.
WSAEMFILE No more socket descriptors are available.
WSAENOBUFS No buffer space is available. The socket cannot be created.
WSAEPROTONOSUPPORT The specified protocol is not supported.
WSAEPROTOTYPE The specified protocol is the wrong type for this socket.
WSAESOCKTNOSUPPORT The specified socket type is not supported in this address family.
建议楼主看MSDN好了!