Solved

FTP with winsock

Posted on 2000-02-14
12
646 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
ID: 2518033
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
ID: 2518046
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
ID: 2518260
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
ID: 2518701
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
ID: 2518982
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
ID: 2522360
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:ekinee
ID: 2522664
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
ID: 2522754
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
ID: 2526021
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
ID: 2526172
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
ID: 2530579
I ended up doing it with WinAPI, but this did however clarify.
0
 
LVL 2

Expert Comment

by:telebasics
ID: 2530692
Good luck
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
This article will show, step by step, how to integrate R code into a R Sweave document
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

911 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

24 Experts available now in Live!

Get 1:1 Help Now