Solved

FTP with winsock

Posted on 2000-02-14
12
634 Views
Last Modified: 2013-11-13
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.
0
Comment
Question by:ekinee
  • 5
  • 4
  • 3
12 Comments
 
LVL 14

Expert Comment

by:mcrider
Comment Utility
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
 
LVL 14

Expert Comment

by:mcrider
Comment Utility
Here is also an FTP server for VB... It may give you some ideas.

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

Cheers!
0
 

Author Comment

by:ekinee
Comment Utility
I'm trying to use VB component.
my computer is in LAN wich is connected out through ISDN router.
0
 
LVL 14

Expert Comment

by:mcrider
Comment Utility
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
 
LVL 2

Expert Comment

by:telebasics
Comment Utility
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
 

Author Comment

by:ekinee
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:ekinee
Comment Utility
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
 
LVL 2

Expert Comment

by:telebasics
Comment Utility
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
 

Author Comment

by:ekinee
Comment Utility
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
 
LVL 2

Accepted Solution

by:
telebasics earned 100 total points
Comment Utility
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
 

Author Comment

by:ekinee
Comment Utility
I ended up doing it with WinAPI, but this did however clarify.
0
 
LVL 2

Expert Comment

by:telebasics
Comment Utility
Good luck
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now