|
{
m_ListenSock=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if(m_ListenSock=INVALID_SOCKET) {
AfxMessageBox(_T("新建SOCKET失败!"));
return;
}
UINT uPort=GetDlgItemInt(IDC_EDIT4);
if(uPort<=0 || uPort>65535){
AfxMessageBox(_T("请输入合适的端口:1-65535"));
goto __Error_End;
}
sockaddr_in service;
service.sin_family=AF_INET;
service.sin_addr.s_addr=INADDR_ANY;
service.sin_port=htons(uPort);
if(bind(m_ListenSock,(sockaddr*)&service,sizeof(sockaddr_in))==SOCKET_ERROR){
AfxMessageBox(_T("绑定端口失败!"));
goto __Error_End;
}
if(listen(m_ListenSock,5)==SOCKET_ERROR){
AfxMessageBox(_T("监听失败!"));
goto __Error_End;
}
sockaddr_in clientAddr;
int iLen=sizeof(sockaddr_in);
SOCKET accSock=accept(m_ListenSock,(struct sockaddr*)&clientAddr,&iLen);
if(accSock=INVALID_SOCKET){
AfxMessageBox(_T("接受客户端失败!"));
goto __Error_End;
}
__Error_End:
closesocket(m_ListenSock);
}
聊天室Dlg.cpp
D:\bs\聊天室\聊天室Dlg.cpp(270) : error C2362: initialization of 'accSock' is skipped by 'goto __Error_End'
D:\bs\聊天室\聊天室Dlg.cpp(265) : see declaration of 'accSock'
D:\bs\聊天室\聊天室Dlg.cpp(270) : error C2362: initialization of 'iLen' is skipped by 'goto __Error_End'
D:\bs\聊天室\聊天室Dlg.cpp(264) : see declaration of 'iLen'
D:\bs\聊天室\聊天室Dlg.cpp(270) : error C2362: initialization of 'accSock' is skipped by 'goto __Error_End'
D:\bs\聊天室\聊天室Dlg.cpp(265) : see declaration of 'accSock'
D:\bs\聊天室\聊天室Dlg.cpp(270) : error C2362: initialization of 'iLen' is skipped by 'goto __Error_End'
D:\bs\聊天室\聊天室Dlg.cpp(264) : see declaration of 'iLen'
D:\bs\聊天室\聊天室Dlg.cpp(270) : error C2362: initialization of 'accSock' is skipped by 'goto __Error_End'
D:\bs\聊天室\聊天室Dlg.cpp(265) : see declaration of 'accSock'
D:\bs\聊天室\聊天室Dlg.cpp(270) : error C2362: initialization of 'iLen' is skipped by 'goto __Error_End'
D:\bs\聊天室\聊天室Dlg.cpp(264) : see declaration of 'iLen'
执行 cl.exe 时出错.
跟着视屏走的但还是报错。求解!!! |
上一篇: 求助,计算俩圆交点坐标下一篇: ShellExecuteEx 函数如何返回TRUE与FALSE
|