CString str;
GetDlgItemText(IDC_StartServer, str)
if (str=="开始")
{
SetDlgItemText(IDC_StartServer,"停止");
SOCKET sockSvc;//服务器端socket
SOCKET sockConnect; //连接用的socket
WORD wVersionRequested;//定义socket1.1或者socket2.0
WSADATA wsaData; //定义装载socket版本的变量
int err; //错误变量
wVersionRequested = MAKEWORD(2,2); //定义连接为socket2.0
err = WSAStartup(wVersionRequested, &wsaData); //装载socket2.0支持
if(0 == err)//判断是否装载成功
{
if(LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2)//判断版本号,是否和定义的一样
{
WSACleanup(); //若出问题,卸载支持,并结束程序返回-1
}
sockSvc = WSASocket(AF_INET,SOCK_STREAM,0,NULL,0,WSA_FLAG_OVERLAPPED);
}
}
else
{
SetDlgItemText(IDC_StartServer,"开始");
/* if(WSARecv(AcceptSocket,&DataBuf,1,&dwRecvBytes,&Flags,
& AcceptOverlapped, NULL) == SOCKET_ERROR)
{
// 返回WSA_IO_PENDING是正常情况,表示IO操作正在进行,不能立即完成
// 如果不是WSA_IO_PENDING错误,就大事不好了~~~~~~!!!
if(WSAGetLastError() != WSA_IO_PENDING)
{
//那就只能关闭大吉了
closesocket(AcceptSocket);
WSACloseEvent(EventArray[dwEventTotal]);
}
}
*/
}