PDA

Click to See Complete Forum and Search --> : FTP and winsock


Legion
Mar 14th, 2000, 10:00 PM
Hi,

I'm attempting to use the winsock control to access an FTP site and retrieve various files (primarily .zip and .exe)

I've setup two winsock controls :-

The first one connects to the FTP server, sends USER and PASS (anonymous), and then completes the PORT command.

The second listens on the localport sent via the PORT command on the first winsock control.

After this the first winsock control requests the file i require.


I get 'Opening ASCII mode data connection' response through the first control and even a completed '226' control code.

Here's the problem - nothing is sent to the second winsock control. If i change the localport to something other than the one specified by the PORT command before requesting file, i get an error from the FTP server - so i presume(?) there must be communication going on between the ports, yet the standard - winsock2.GetData StrData, vbString - in the Data_Arrival section yeilds nothing!?!

If anyone has any ideas on what i might be doing wrong i'd appreciate the helps.

Oh yeh, i'm using TCP protocol

Thanks,

Matt

privoli
Mar 15th, 2000, 11:56 AM
Your first TCP/IP port is used for sending commands
stuff like ...

USER xxxx
PASS xxxx
PORT xxx,xxx,xxx,xxx,xxx,xxx

Those valuse indicate incoming IP address and listening port. So you must set another winsock to listen on the last port for the specified PORT command. If unsure search for "FTP RFC" in like http://www.yahoo.com

21 = Port used for sending commands
22 = DATA port, only file transfers use this port.

See the RFC if you're a little lost. Cheers

Mar 15th, 2000, 04:30 PM
Try vbBinary instead of vbString and put the retrieved data in a byte array

Oleg Gdalevich
Mar 19th, 2000, 06:41 PM
Take a look at my FTP Client sample application at http://www.vbip.com/winsock/winsock_ftp_client_01.asp

Oleg Gdalevich
Mar 19th, 2000, 07:47 PM
Take a look at my FTP Client sample application at http://www.vbip.com/winsock/winsock_ftp_client_01.asp

Legion
Mar 19th, 2000, 10:12 PM
Thanks for the help everyone.

Oleg - I found your webpage a couple of days back. Extremely helpful; Best information i've found on the net about the winsock control. i've already referred a few other people to it.

I eventually found the problem - i wasn't closing the second winsock control after receiving an inbound connection (it's always the little things.) Anyhow, all's working great now.

Thanks again,

Legion