PDA

View Full Version : Help from the programmers of FlashFXP


Luca
06-06-2003, 02:48 AM
Maybe this is not the right place, since I know you have better things to do, but could you spend some moments and look after my little ftp client to see why it doesn't work ?

The problem is that sometimes it prints the LIST - ing of a directory and sometimes it doesn't.....

Could you tell me why?

The source code is in the attachment

I know you are busy people, but I also know you can help me, since your client FTP is very good, if not the best :)

P.S. of course my idea is not to create a commercial product to "steal" your buyers :p :p

MxxCon
06-06-2003, 02:58 AM
your code is in C++
FlashFXP is in Delphi :)

Luca
06-06-2003, 03:35 AM
Like Homer Simpsons would say....... DOH!

Luca
06-06-2003, 07:16 AM
At the moment, I have no time, but when I'll come back home, I'll explain what I do when I connect to the ftp, cause also if the programming language is not the same, the "mechanism" behind the client is the same :)

I hope you will answer me.

If you don't have time or you dfon't want to help me, plz tell me, also if i hope, you will help me :)

Luca
06-06-2003, 02:42 PM
Here is what my program do.

I hope the comments are enough for you, so you can help me :)


void ftp_passivelist (int *fd)
{
struct sockaddr_in server; // structure with the info taken from the PASV command (ip & port)
int p1 = 0, p2 = 0; // integer number containing the port numbers in the internert notation
int dataC; // socket used for the data connection

MakeSocket (&dataC); // initialization of the socket

memset (&server, 0, sizeof (server)); // nothing important

// used to take the ip and the port from the message returned by the PASV command
sscanf (buffer, "227 Entering Passive Mode (%d,%d,%d,%d,%d,%d)", &server.sin_addr.S_un.S_un_b.s_b1,
&server.sin_addr.S_un.S_un_b.s_b2,
&server.sin_addr.S_un.S_un_b.s_b3,
&server.sin_addr.S_un.S_un_b.s_b4,
&p1, &p2);

// just a debug print to see if the info correspond to the reply of the PASV command
printf ("--> (%d,%d,%d,%d,%d,%d)", server.sin_addr.S_un.S_un_b.s_b1,
server.sin_addr.S_un.S_un_b.s_b2,
server.sin_addr.S_un.S_un_b.s_b3,
server.sin_addr.S_un.S_un_b.s_b4,
p1, p2);

server.sin_port = htons ((p1 * 256) + p2); // the port number
server.sin_family = AF_INET; // nothing important

printf (" --> %d\n\n", (p1 * 256) + p2); // another debug print

send (*fd, "LIST \r\n", 7, 0); // send of the LIST command \r\n are the telnet end of line

// connecting to the port specified by the ftp server
if (connect (dataC, (struct sockaddr *)&server, sizeof (server)) < 0)
printf ("error connect");

GetReply (fd); // receive of the reply to the LIST command from the control connection

int a;

// this SHOULD be the receiving of the listing from the data connection and it's printing
while ((a = recv (dataC, buffer, sizeof (buffer), 0)) > 0)
{
printf ("%s", buffer);
}

// after i've received the lidting, I close the data connection
#if (defined (_WIN32) || defined (WIN32))
closesocket (dataC);
#else
close (dataC);
#endif

printf ("\n\n"); // nothing important

GetReply (fd); // receive of the reply to the LIST command after the receiving of the file
// listing
}

Luca
06-07-2003, 07:25 AM
Nevermind, now my program works :) :)

Sorry if I'have bothered you all :)