}else
{
AfxMessageBox(_T("获取文件总大小失败!"));
}
}else
{
AfxMessageBox(_T("连接服务器失败、请确认IP地址或端口号!"));
}
closesocket(sockClient);//关闭套接字
}
void CRecvFileClientDlg::ConnectServer()
{
if (InitSocket())
{
DWORD strIp =NULL;
CString strPort = _T("");
((CIPAddressCtrl*)GetDlgItem(IDC_IP))->GetAddress(strIp);
GetDlgItem(IDC_PORT)->GetWindowText(strPort);
if (strIp==NULL||strPort=="")
{
AfxMessageBox(_T("Ip地址或Port端口号不能为空!"));
}else
{
int port = atoi(strPort.GetBuffer(1));
ConnectRecvFileData(strIp,port);
}
}
}
小结:最近用到些socket 网络编程的东西,所以就试着写了个基本的C/S端数据的网络传输,有哪些不足的地方,请看到的前辈们不吝赐教!!!
摘自 wainiwann