FTP with winsock

I'm attempting to use winsock VB 5.0 for file transferring over the net.
I'm able to make connect to a protected server, but I'm unable to transfer files. I need to send files to that server. I'm working behind router.
If anyone would know something about this.
ekineeAsked:
Who is Participating?
 
telebasicsConnect With a Mentor Commented:
I used 2 winsocks one wich connects to the server on port 21 and one wich lsiten's on the port stated with PORT command to server.
Your Ip adress is in the winsock.localip
replace the . for , and add the port ,4,1 and your port command is ready. when you state a stor or retr command the server will trie to connect to that port wich is listened to by the second winsock, you accept this connection and startg sending the file or start retrieving the file.
0
 
mcriderCommented:
Are you trying to use the winsock control or winsock API?

If you're using the API, check out the following microsoft KB article:

FILE: VBFTP.EXE: Implementing FTP Using WinInet API from VB
http://support.microsoft.com/support/kb/articles/Q175/1/79.ASP?LNG=ENG&SA=MSDN&FR=1 
 
Do you mean you're behind a firewall?


Cheers!
0
 
mcriderCommented:
Here is also an FTP server for VB... It may give you some ideas.

ftp://ftp.caas.com/pub/ftpserver.zip 
 

Cheers!
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
ekineeAuthor Commented:
I'm trying to use VB component.
my computer is in LAN wich is connected out through ISDN router.
0
 
mcriderCommented:
Why not just use the Microsoft Internet Transfer Control (MSINET.OCX)... It has FTP built into it.  Just add it to your project and then check out the help pages... They're actually pretty good...


Cheers!
0
 
telebasicsCommented:
Can you transfer files to an unprotected server?

Cause to transfer files you will need the Port command to state to wich port the server should connect at you client machine (other than the port you are sendeing the commands with), after that the server will connect to your machine on that port (after you give the STOR command that is) as soon as you accept the connection you can send the contents of the file and when your done close the connection stating an EOF by doing that.

Therefor if your behind a firewall / router wich blocs all ports, you will have to open the port you are going to use on the firewall.
0
 
ekineeAuthor Commented:
I have tried Microsoft Internet Transfer Control and it makes path letters and filename in uppercase so, meaning menu.html will be MENU.HTML. This doesn't work for my purposes.
0
 
ekineeAuthor Commented:
To telebasics.

I have studied RFC959, and know PORT command format. But I do not know how to get this TCP port address.
If you could enlighten me how to form it.
0
 
telebasicsCommented:
the PORT command goes like this
PORT 10,0,0,1,3,4
 the first 4 pairs are the IP number of your machine (winsock.localIp)
The second to pairs are a pain in the but. they are one of two 8bit.
3 = 00000011
4 = 00000100
they form
0000001100000100 = 772

so if you want to use port 1025
you will need

0000010000000001 = 1025
split up the long ip string
00000100 = 4
and
00000001 = 1

getting a port string of
10,0,0,1,4,1

If someone has a nice routine doing this automaticly i want it.

The port on your local machine must be 1024 up

You will need to use a free PORT in this action, i haven't figured out how to get a free port automaticly from winsock and rebuild it to ,4,1 to be used in the PORT command. But being a little less flexible i use the 1025 PORT (,4,1) and it works most of the time.

after the STOR or RETR commands are given the server will connect on this port (so you will have to listen and accept the connection)
0
 
ekineeAuthor Commented:
I'm working behind a firewall, and I don't have solid IP address,but it is on our network provider, so you sead I had to open a Port myself.
How do I do that.
0
 
ekineeAuthor Commented:
I ended up doing it with WinAPI, but this did however clarify.
0
 
telebasicsCommented:
Good luck
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.