Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need URGENT help wit FTP Programming

Status
Not open for further replies.

cpbee

Programmer
Dec 27, 2001
3
CH
Hello,

I need help for some FTP programming. I tried some other places, but nobody could help me. So my prob is: I want to code some FTP Client, that automatically downoads some stuff from a site. The whole thing should be or is started in WinAPÎ... with raw Sockets. I mangaged to get a connection to the FTP server, also the login and password submission works fine. The problem starts with some more advanced commands. Like List and / or Retrieve. I know the commands (got them from the RFC 959) but somehow I don't get them working. If I call for the "LIST" command, it arrives at the server, but I don't get any answer.
What do I wrong? Could anybody help me with that specific problem? Does anybody know a source of FTP Client that uses Raw Sockets?

I would be very thankful if anybody could help me!!!

chris.

(Here is some code I use.. "send" sends the message and I capture the server answer with "retrv").

bool TheFTP::entrPassv()
{
int pos;
//Set Current Working directory
sprintf(message,"CWD\r\n");
send(s,message,strlen(message),0);
getServerAnswer();

//Print Current Working directory
sprintf(message,"pwd\r\n");
send(s,message,strlen(message),0);
getServerAnswer();

//Set to Binary Mode
sprintf(message,"TYPE A\r\n");
send(s,message,strlen(message),0);
getServerAnswer();

//get Passive Mode IP and Port
sprintf(message,"PASV \r\n");
send(s,message,strlen(message),0);
getServerAnswer();

//get Passive Mode stuff
pos=strcspn(bf,"(");
sprintf(passivePort,&bf[pos+1]);
pos=strlen(passivePort);
passivePort[pos-3]='\0';
/*
//set Passive Mode Port
sprintf(message,"PORT *********\r\n");
//strcat(message,passivePort);
//strcat(message,"\r\n");
send(s,message,strlen(message),0);
getServerAnswer();

*/
getDirList();

return true;
}

bool TheFTP::getDirList()
{

sprintf(message,"LIST\r\n");
send(s,message,strlen(message),0);

getServerAnswer();


return true;

}




 
Hey,

I think your problem is that you need to send the commands in ascii mode, but when recieving files you choose what mode you want.

I have sources of FTP client/server that wrote before 7 years when i was 9... i'll find it for you. it is in Visual c++ 5 or 4, so you will have to convert the .mak files to dsp, but its done automatically so what am i talking about???

See ya,
I'm going to sleep
its very late here in israel now... and i have school tomorrow...
bye,
Daniel Cohen Gindi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top