哪些情况运行CSocket中create()会失败?

zhengda1936 2004-06-29 10:56:35
我从CSocket继承了一个类,然后运行create(),结果失败了。
请问哪些情况下运行create()会失败?
还有create()是干什么用的?
...全文
195 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
lmf_1 2004-07-01
  • 打赏
  • 举报
回复
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好了!
Caps77 2004-07-01
  • 打赏
  • 举报
回复
网线被拔掉也会失败
月吻长河 2004-07-01
  • 打赏
  • 举报
回复
这是因为你创建工程的时候没有选择Socket支持。
你按照alphapiao(奉旨灌水钦差)的方法就可以解决
danielzhu 2004-06-30
  • 打赏
  • 举报
回复
1.在stdafx.h文件里,#include <afxsock.h>


2.在CxxApp的initinstance()里需要调用
afxinitsocket();
代码如下:
BOOL CTestModuleApp::InitInstance()
{
//Update by Daniel Zhu
if (!AfxSocketInit())
{
AfxMessageBox(_T("Windows 通信端口初始化失败"));
return FALSE;
}
//AfxMessageBox("Windows 通信端口初始化成功");
return CWinApp::InitInstance();
}
alphapiao 2004-06-29
  • 打赏
  • 举报
回复
在stdafx()里,#include <afxsock.h>
在initinstance里需要调用afxinitsocket();
create创建一个socket对象
nineclock 2004-06-29
  • 打赏
  • 举报
回复
1#include <afxsock.h>

2afxinitsocket()

18,356

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧