|
极其郁闷的话题
三楼的方法刚试了下——写过WSAStartup也连接了库文件,依然报1楼或4楼的错误 |
|
极其郁闷的话题
相关代码如下,工程名为Chat,用WSA系列异步套接字只能用winsock2.h BOOL CChatDlg::InitSocket() { m_socket=WSASocket(AF_INET,SOCK_DGRAM,0,NULL,0,0); if(INVALID_SOCKET==m_socket) { MessageBox("创建套接字失败"); return FALSE; } SOCKADDR_IN addrSock; addrSock.sin_addr.S_un .s_addr=htonl(INADDR_ANY); addrSock.sin_family=AF_INET; addrSock.sin_port=htons(6000); if(SOCKET_ERROR==bind(m_sockt,(SOCKADDR*)&addrSock,sizeof(SOCKADDR))) { MessageBox("绑定失败"); return FALSE; } if(SOCKET_ERROR==WSAAsyncSelect(m_socket,m_hWnd,UM_SOCK,FD_READ)) { MessageBox("注册网络读取事件失败"); return FALSE; } return TRUE; } #include <winsock2.h>放在StdAfx前部报错Windows重包含,放在StdAfx后部报错如下 E:\VS\Workspaces\Chat\ChatDlg.cpp(180) : error C2039: 'S_un' : is not a member of '__unnamed' e:\vs\vc98\include\winsock2.h(311) : see declaration of '__unnamed' E:\VS\Workspaces\Chat\ChatDlg.cpp(180) : error C2228: left of '.S_addr' must have class/struct/union type E:\VS\Workspaces\Chat\ChatDlg.cpp(183) : error C2065: 'm_sockt' : undeclared identifier E:\VS\Workspaces\Chat\ChatDlg.cpp(188) : error C2065: 'UM_SOCK' : undeclared identifier |
|
极其郁闷的话题
补充一下,我没有为对话框添加WOSA支持,如果勾选了该选项则会在StdAfx头文件后部自动加上#include <afxsock.h>并且在C工程名App::InitInstance()里自动添加 if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } 当然无论添加支持与否都无法通过编译 |
|
终于100kx了
默默的潜水,技术有限,不敢乱发帖误导人 |
|
小小的建议
更正一下,购买和转正的链接都找到了,可是还是觉得不太合理,能不能把它们弄到一起,尤其是“邀请注册”在老下面,不方便看到 |
|
|
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值