socket编程能正常连接但不能登录
我在c++builder6用socket与ftp服务器进行操作,能够建立连接,但是一直提示530 User username con not login.
但是有的服务器就能够正常登录。
不知道为什么,代码如下:
String strRecv = "";
MultiThreadDealSocket *dealSocket = new MultiThreadDealSocket();
SOCKET client = dealSocket->GetConnect(host,port);
strRecv = ReadLine(client);
if(client == NULL) return NULL;
String user = "USER "+userName+"\r\n";
send(client,user.c_str(),user.Length(),0);
strRecv = ReadLine(client);
if(GetCode(strRecv) == "331")
{
String password = "PASS "+pass+"\r\n";
send(client,password.c_str(),password.Length(),0);
strRecv = ReadLine(client);//这里一直返回信息:530 User username con not login.
}
[解决办法]
错啦,必需按照ftp协议,传送数据。