问题描述
- 用Socket编写的ftp客户端无法建立连接
- 编写一个ftp客户端,用的MFC,CAsyncSocket类
CClientSocket类继承自CAsyncSocket类,
定义了CClientSocket m_ClientSocket;这是按下连接“连接”按钮后的处理函数:
void CChatClientDlg::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE);
char send_buf[100];
m_ClientSocket.Create();
m_ClientSocket.Connect(ServerIPsPort);
m_ListWords.AddString(_T(""connecting...""));
}重写了OnConnect函数:
void CClientSocket::OnConnect(int nErrorCode)
{
// TODO: 在此添加专用代码和/或调用基类
if (nErrorCode)
{
AfxMessageBox(_T(""Fail to connect!Please try again!""));
return;
}
else AfxMessageBox(_T(""Successful!""));
//return;}
问题来了,每次我输入ftp地址(比如ftp.zju.edu.cn)和端口号(21)并按了“连接”按钮后,要么弹出""Fail to connect!Please try again!”的对话框,要么压根没反应肿么办啊啊啊啊。。。
时间: 2024-08-04 15:00:33