How does FTP Work?
How does FTP Work?
How does FTP Work?
How does FTP Work?
How does FTP Work?
How does FTP Work? How does FTP Work? How does FTP Work? How does FTP Work? How does FTP Work? How does FTP Work? How does FTP Work? How does FTP Work?
How does FTP Work? How does FTP Work?
How does FTP Work?
Go Back  Xtreme Visual Basic Talk > > > How does FTP Work?


Reply
 
Thread Tools Display Modes
  #1  
Old 12-17-2007, 12:33 PM
VB_Alien VB_Alien is offline
Senior Contributor
 
Join Date: Apr 2004
Posts: 854
Default How does FTP Work?


I downloaded a vb FTP program from PSC. One is a server and one
is the client. After toying around with it a little, i got it to working
on my pc. This one transfers files. The server acts like a server and
a client and then i got just a client program.

I was under the impression that a server was only used as a server
so that a client could go through it to be able to transfer files to a different
client. Sort of like yahoo chat. It has FTP built into also.

What i want to do is setup a server on my puter and the client would be
on my daughters puter. She's always wanting something off my puter
and i'm tired of burning cd's for her all the time so this would work out
great for me.

Yes, i know yahoo chat would do what i want but i want the experience
of making my own.

So anyway. Could someone explain to me what i need to do here? Do i need
to setup a server and a client on my pc and a client on hers or do we both
need a server and a client? Thank-you
Reply With Quote
  #2  
Old 12-17-2007, 03:31 PM
loquin's Avatar
loquinHow does FTP Work? loquin is offline
Google Hound

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Arizona, USA
Posts: 12,400
Default

FTP stands for File Transmission Protocol.

An FTP server allows a client to access its files; the client may download file(s) and/or upload file(s.)

That's it. An FTP server may allow access to many clients "simultaneously," but, each client communicates with the server only. NOT to other clients.
__________________
Lou
"I have my standards. They may be low, but I have them!" ~ Bette Middler
"It's a book about a Spanish guy called Manual. You should read it." ~ Dilbert
"To understand recursion, you must first understand recursion." ~ unknown
Reply With Quote
  #3  
Old 12-17-2007, 04:02 PM
the master's Avatar
the master the master is offline
Tachikoma
 
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,596
Default

You need the server app on your PC and the client on hers.

Are you in the same house? If you are then a network share would be a lot easier, faster and less prone to errors. I see FTP as quite a weak protocol.

If you really want to make a program to transfer files then you could think about making your own protocol. Nothing too complicated. Just a simple directory list and transfer would work. This depends how much you know about these things tho so the network share would be the best idea
__________________
"That which seems simple is often overlooked" ~ me
Halloween 2014 Yard Haunt
Halloween Special FX
Reply With Quote
  #4  
Old 12-17-2007, 04:35 PM
VB_Alien VB_Alien is offline
Senior Contributor
 
Join Date: Apr 2004
Posts: 854
Default

Thanks loquin and master:

Ok. I know what happens when a server sends a file or text to a client
but what happens when the client wants to send something? Does it go
to the server and the server sends it on to the client?

the master:

Yes. She would be in my house when we do this as she doesnt have an
internet connection at her house yet but when she does, i still want to
be able to do the same thing. Currently i'm using a router that enables
me to be wireless on the internet.
Reply With Quote
  #5  
Old 12-17-2007, 05:17 PM
Robert Collins Robert Collins is offline
Contributor
 
Join Date: May 2004
Posts: 695
Default

Ok. I know what happens when a server sends a file or text to a client
but what happens when the client wants to send something? Does it go
to the server and the server sends it on to the client?


No. The client does not send stuff to the server and then the server turns around and sends it on to another client.

FTP is both ways. Server to Client (download) and Client to Server (Upload) but only one at a time. Client can upload to Server. Server places stuff where Client specified (within the allowable folders on the Server). Another Client downloads same stuff from same folder from the Server.

Simply think of this site as a Client/Server FTP situation. You the Client can download zip files from here (the Server) posted by members, etc. You, as the Client can also upload zip files to one of your posts. Although this is not really FTP is the strict sense it does act similar to how FTP functions.



.
Reply With Quote
  #6  
Old 12-17-2007, 07:10 PM
PrOpHeT's Avatar
PrOpHeTHow does FTP Work? PrOpHeT is offline
Hopelessly confused...

* Expert *
 
Join Date: Mar 2001
Location: Tyler, Tx.
Posts: 3,055
Default

well there are these little magic elves, when they are not making cookies they moonlight as data curiers....

In all seriousness though...

http://www.faqs.org/rfcs/rfc959.html
and
http://www.faqs.org/rfcs/rfc1579.html

all you ever wanted to know about FTP

All that said be aware that seldom do any clients or servers adhere strictly to the RFC, the best way to learn is to set up a FTP server if you are running XP Pro go to add remove programs/windows components/Internet Information Services (IIS)

From there you can use it and the command line ftp tools to play with all of the syntax.
__________________
When you earnestly believe you can compensate for a lack of skill by doubling your efforts, there's no end to what you can't do ;)

For the love of Gold...
Reply With Quote
  #7  
Old 12-17-2007, 07:19 PM
Robert Collins Robert Collins is offline
Contributor
 
Join Date: May 2004
Posts: 695
Default

DJ Smithy post a link to a nice easy to make FTP Server

Simple ftp program





EDIT

Correction. I believe it's an FTP Client

Last edited by Robert Collins; 12-17-2007 at 07:28 PM.
Reply With Quote
  #8  
Old 12-17-2007, 09:46 PM
VB_Alien VB_Alien is offline
Senior Contributor
 
Join Date: Apr 2004
Posts: 854
Default

OK. I think i'm getting a grasp on it now but i need to know
one more thing.

In the winsock control, in the dataarrival sub, How can i determine
if the data being sent is binary or just straight text as in text in a
textbox.

I thought i would implement text messaging as well in my program.

Thanks
Reply With Quote
  #9  
Old 12-17-2007, 10:01 PM
Roger_Wgnr's Avatar
Roger_Wgnr Roger_Wgnr is offline
CodeASaurus Hex

Forum Leader
* Expert *
 
Join Date: Jul 2006
Location: San Antonio TX
Posts: 2,427
Default

Oh to re-invent things.

1st off to answer your question.
All data is binary in nature as it is sent. You need to specify in your data stream if it is a text message or file transfer (I have not done much with this myself).

2nd - For what you are trying to do why re-invent the wheel UltraVNC is free and provides the following
Quote:
Security: Build-in communication encryption (TWF 256) and DH key exchange (using a 512 prime)
File transfer (using clipboard style Copy/Paste : ctr-alt-c, ctrl-alt-v)
Text Chat
Clipboard transfer (Text, RTF, HTML, pictures)
Scalable and easy to use Viewer. Various color modes to fit bandwidth at best
International keyboard support
Additional password if wanted
__________________
Code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live. ~Martin Golding
The user is a peripheral that types when you issue a read request. ~Peter Williams
MSDN Visual Basic .NET General FAQ
Reply With Quote
  #10  
Old 12-17-2007, 10:03 PM
Robert Collins Robert Collins is offline
Contributor
 
Join Date: May 2004
Posts: 695
Default

FTP uses two sockets. One socket is for FTP commands and the other socket is for the data. Commands are always text. Data can be anything.

Therefore you will have two DataArrival Events.
Reply With Quote
  #11  
Old 12-17-2007, 10:49 PM
DougT's Avatar
DougT DougT is offline
Ultimate Antique

Administrator
* Expert *
 
Join Date: Sep 2005
Location: Maldon,Essex, UK
Posts: 3,939
Default

Quote:
Originally Posted by VB_Alien View Post
OK. I think i'm getting a grasp on it now but i need to know
one more thing.

In the winsock control, in the dataarrival sub, How can i determine
if the data being sent is binary or just straight text as in text in a
textbox.

I thought i would implement text messaging as well in my program.

Thanks
If you're going to do this you will have to add to the existing protocol and have some sort of command to identify the data as being a Text Message. You will therefore have eithier an If or Case statement checking for the command, when you get a match you know that it will be text (by definition).

[Opinion]
Whilst I appreciate your desire to do this to get some experience / knowledge I would suggest that trying to modify someone elses FTP code is the difficult way to do it (especially if it's come from PSC ). A 'better' way might be to create a Chat C/S with the ability to transmit and receive files.
[/Opinion]
__________________
semel insanivimus omnes
S Data in context = Information, S Information in context = Knowledge, S Knowledge in context = Experience
S Experience in context = Wisdom= Data
Reply With Quote
  #12  
Old 12-17-2007, 11:12 PM
the master's Avatar
the master the master is offline
Tachikoma
 
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,596
Default

Quote:
Originally Posted by Robert Collins View Post
FTP uses two sockets. One socket is for FTP commands and the other socket is for the data.
Does anyone else find this a really annoying feature? The custom FTP protocol ive made can send both commands and data through a single socket without curruption. The double socket thing is usually where FTP fails... Thats if you can get a reliable directory list in the first place. I know re-inventing isnt always the best option but with FTP it probably is. Especially if you want to add extra features. Mine supports editing SQL databases etc too.

End of the day though existing remote admin software would be a lot easier. VNC works but Radmin 3 is really good. The only problem is that its so good you have to pay for it
__________________
"That which seems simple is often overlooked" ~ me
Halloween 2014 Yard Haunt
Halloween Special FX
Reply With Quote
  #13  
Old 12-18-2007, 12:10 AM
MikeJ's Avatar
MikeJHow does FTP Work? MikeJ is offline
Retread

Retired Moderator
* Expert *
 
Join Date: Sep 2002
Location: Austin, Texas
Posts: 6,747
Default

I may be totally off base here, but I believe the reason why FTP has the dual socket layer is because of the ability to allow asynchronous handling via the REST command? If one socket is loaded down with both commands and data, it would be impossible to use commands to stop file transfer or pause it, etc. The dual nature was provided to creade a thread-like interface with a server, I believe.
__________________
{ Lex Fori } { Locus Classicus } { Rutilus Scrinium }
Osculare pultem meam!
Reply With Quote
  #14  
Old 12-18-2007, 12:17 AM
the master's Avatar
the master the master is offline
Tachikoma
 
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,596
Default

Ive solved all that on the single socket method
__________________
"That which seems simple is often overlooked" ~ me
Halloween 2014 Yard Haunt
Halloween Special FX
Reply With Quote
  #15  
Old 12-18-2007, 12:47 AM
Rockoon's Avatar
Rockoon Rockoon is offline
Joseph Koss

* Guru *
 
Join Date: Aug 2003
Location: Unfashionable End
Posts: 3,615
Default

Quote:
Originally Posted by the master View Post
Ive solved all that on the single socket method
Did you solve it but still allow for being many packets behind when the sender has a much higher bandwidth than the reciever?

That is a key feature of efficient file transfer protocols. The sender can be way ahead of the reciever... this allows the sender to batch up the jobs it has in front of it and handle them in larger blocks.. send user A a dozen packets, then send B a dozen packets, then send C a dozen packets, back to user A, then B, then C, ....
Reply With Quote
  #16  
Old 12-18-2007, 01:57 AM
the master's Avatar
the master the master is offline
Tachikoma
 
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,596
Default

The way i do it is to send so much data from the client at a time. The client can decide how much. When its sent it (usually only takes a few seconds) the server will reply saying if it was sent ok. This allows the client to re-send the bit of data if it got currupted (and yes this does still happen). It also allows the client to send any commands that are waiting.

I know that technically this makes transfering files a little slower but not by a whole lot. Im willing to sacrafice a few seconds to save hours of fixing connection problems and to ensure non-currupted data.

I also use a new type of file list that can return data in more various styles than the current FTP protocol but can be understood by any client supporting my protocol. It can also save bandwidth by only showing the user the data they want to see (hey, i got my few seconds back )

I might post some code up in the tech discussions forum so we can discuss the pros and cons of the whole idea (when i get time)
__________________
"That which seems simple is often overlooked" ~ me
Halloween 2014 Yard Haunt
Halloween Special FX
Reply With Quote
  #17  
Old 12-18-2007, 09:25 AM
VB_Alien VB_Alien is offline
Senior Contributor
 
Join Date: Apr 2004
Posts: 854
Default

Would i be making my own commands that would determine
if the data being sent is text or a file transfer?

To illustrate:

In one command button i have this:

Code:
Dim MyCommand As String MyCommand = "Text" & "The data" ' <--- Mock data Text1.Text = Left(MyCommand, 4) ' Gives me the command "Text" Text2.Text = Mid(MyCommand, 5) ' The actual data



In another command button i have this:

Code:
Dim MyCommand As String MyCommand = "Data" & "This is binary data" Text1.Text = Left(MyCommand, 4) ' Gives me the command "Data" Text2.Text = Mid(MyCommand, 5) ' The Data

Is this how i would go about determining what type of data
is being sent?
Reply With Quote
  #18  
Old 12-18-2007, 09:41 AM
Robert Collins Robert Collins is offline
Contributor
 
Join Date: May 2004
Posts: 695
Default

That would work but I don't understand why you need to be concerned about it. If you want to add a text messaging to your FTP program then you already know that it will be text. If someone types into a textbox and sends it to your server or you type into a textbox on your server and send it to a client then it is already in text format.
Reply With Quote
  #19  
Old 12-18-2007, 10:06 AM
the master's Avatar
the master the master is offline
Tachikoma
 
Join Date: Mar 2003
Location: Mansfield, UK
Posts: 4,596
Default

He means he wants to know if its a message. Obviously text or binary or whatever makes no difference.

The answer is that yes you have to add a new command. You send the command followed by the data. At the other end you check for that command and if you get it then you display the data to the other user.

For simplicity i would disable newlines. FTP recognises a newline as the end of a command/data line and will chop off your message before it even gets to your check for the command
__________________
"That which seems simple is often overlooked" ~ me
Halloween 2014 Yard Haunt
Halloween Special FX
Reply With Quote
  #20  
Old 12-18-2007, 10:22 AM
VB_Alien VB_Alien is offline
Senior Contributor
 
Join Date: Apr 2004
Posts: 854
Default

OK people. Thanks for all the help. I think i got the idea now so
i'll give it a go and see what happens.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
How does FTP Work?
How does FTP Work?
How does FTP Work? How does FTP Work?
How does FTP Work?
How does FTP Work?
How does FTP Work? How does FTP Work? How does FTP Work? How does FTP Work? How does FTP Work? How does FTP Work? How does FTP Work?
How does FTP Work?
How does FTP Work?
 
How does FTP Work?
How does FTP Work?
 
-->