他里面有一个login方法public boolean login(String username, String password) throws IOException
{
user(username);//发送name给服务器 if (FTPReply.isPositiveCompletion(_replyCode))//返回的code>=200&&code<300
return true; // If we get here, we either have an error code, or an intermmediate
// reply requesting password.
if (!FTPReply.isPositiveIntermediate(_replyCode))//code >=100&&code<200
return false; return FTPReply.isPositiveCompletion(pass(password));
}我模仿着这个方法写了一个方法,现在我通过connect(ip, port);和网上的一个jsp服务器用端口21建立了连接,然后就开始用下面的方法登录,其中name和password都是正确的,然后单步调试观察他的执行过程:
开始发送name,服务器返回:220,然后发送密码,但这时服务器返回的是331 passwordrequired for然后我又在他下面发送了一遍密码,然后才返回了230登陆成功。我就想问,为什么第一次发送密码,服务器没返回230呢,发送密码前还要再发送什么信息么?????public boolean login(String name,String password) throws IOException{
sendCommand("USER", name);
if ((replyCode>=200)&&(replyCode<300)){
sendCommand("PASS", password);
//sendCommand("PASS", password);
//为什么第一次发送密码,服务器没返回230呢,发送密码前还要再发送什么信息么
if((replyCode>=200)&&(replyCode<300))
return true;
else {
return false;
}
}
else return false;
}
{
user(username);//发送name给服务器 if (FTPReply.isPositiveCompletion(_replyCode))//返回的code>=200&&code<300
return true; // If we get here, we either have an error code, or an intermmediate
// reply requesting password.
if (!FTPReply.isPositiveIntermediate(_replyCode))//code >=100&&code<200
return false; return FTPReply.isPositiveCompletion(pass(password));
}我模仿着这个方法写了一个方法,现在我通过connect(ip, port);和网上的一个jsp服务器用端口21建立了连接,然后就开始用下面的方法登录,其中name和password都是正确的,然后单步调试观察他的执行过程:
开始发送name,服务器返回:220,然后发送密码,但这时服务器返回的是331 passwordrequired for然后我又在他下面发送了一遍密码,然后才返回了230登陆成功。我就想问,为什么第一次发送密码,服务器没返回230呢,发送密码前还要再发送什么信息么?????public boolean login(String name,String password) throws IOException{
sendCommand("USER", name);
if ((replyCode>=200)&&(replyCode<300)){
sendCommand("PASS", password);
//sendCommand("PASS", password);
//为什么第一次发送密码,服务器没返回230呢,发送密码前还要再发送什么信息么
if((replyCode>=200)&&(replyCode<300))
return true;
else {
return false;
}
}
else return false;
}
1,先连接,服务器返回220
2,USER 服务器返回331
3,PASS 服务器返回230