Building FTP Server

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Building FTP Server

Post by Nakia » Sun Jan 27, 2013 5:30 am

Hi,

Not sure of the complexity of this task but would it be hard to build a simple FTP Server?
Doesn't need all the bells and whistles but just need control over it more so than what I can achieve from other products out there right now.

Have successfully used sockets before in a TCP Telnet Client application but to be honest not sure where to start with a FTP Server (if its at all possible)

Am I biting off more than I can chew with this?

- Things to note:
1. User will need to select base directory before starting the server
2.Server will communicated to from iOS Only and the Server will need to publish itself on the Bonjour service (think I can manage the Bonjour registration and publication part)
3. Server will only ever be receiving plain text files.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10058
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Building FTP Server

Post by FourthWorld » Sun Jan 27, 2013 7:29 am

You could write it, but it would be a bit of work and you'd still be dealing with the downsides of FTP. Do you need some specific aspect of FTP which would prevent you from using a simple CGI over http? An HTTP version would be easier to build for medium-to-small files, and likely much faster.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Building FTP Server

Post by Nakia » Sun Jan 27, 2013 8:56 am

FourthWorld wrote:You could write it, but it would be a bit of work and you'd still be dealing with the downsides of FTP. Do you need some specific aspect of FTP which would prevent you from using a simple CGI over http? An HTTP version would be easier to build for medium-to-small files, and likely much faster.
Hmmm, well there is no reason it cant be HTTP thinking about it.
Things it needs to do follows:
1 - Be able to receive small text files
2 - Base directory set before the "Service" starts
3 - Be fool proof, no playing with firewalls and the likes

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10058
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Building FTP Server

Post by FourthWorld » Sun Jan 27, 2013 9:48 am

1. Easy

2. Not sure what that means

3. Firewalls vary so much that no truly foolproof design is possible. That said, you're likely to encounter far fewer problems with HTTP than you would with FTP.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Building FTP Server

Post by Nakia » Sun Jan 27, 2013 10:11 am

Any examples around the place that you know of?

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10058
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Building FTP Server

Post by FourthWorld » Sun Jan 27, 2013 10:17 am

There's not much to it: on the client side use the POST command, and on the server get the data from the $GET_POST array. Much easier than writing an FTP server. :)

This Lesson may help:
http://lessons.runrev.com/s/lessons/m/4 ... ode-server

Here are more on working with RevServer:
http://lessons.runrev.com/s/lessons/m/4070
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Building FTP Server

Post by Nakia » Sun Jan 27, 2013 10:25 am

Okay,

Looks like its just for LC Server though or am I miss reading the Dictionary?
"$_GET is only available when running in CGI mode (Server)."

FYI, this won't be running on a server but as an application..

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Building FTP Server

Post by sturgis » Sun Jan 27, 2013 4:00 pm

You might look here: http://andregarzia.com/page/revonrockets If a single threaded implementation of a web server in lc will work, then you can learn LOTS from this. It accepts both post and get, can also be adjusted to run specific commands on receipt of data (have only done this with get, it probably works with post too). As it says on the front page, it is NOT a replacement for apache. If you don't need multiple threads, multiple users though, it works really well. I was using it for a while as the receiving end for a remote control app. (android, remote mouse moves and clicks, though the click part requires an external since lc can't click outside its own app windows by default)

Since you already have socket experience, it would be a great stack to learn from if nothing else. Haven't tested with IOS, but android can post and get to it just fine.


EDIT: If you DO need a more heavy duty receiving end, there are enough point and click web servers that can be set up with little knowledge, you can go that direction instead. (and maybe use php as the back end if you don't have a license to lc server)

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Building FTP Server

Post by Nakia » Sun Jan 27, 2013 10:02 pm

Thanks Sturgis,

I have actually been thinking that maybe I could just the rresockets external (for iOS) and simply devise up my own transfer method.
Seeing as though I am only wanting to transfer small text files this should work shouldn't it?

Just looking at that HTTP Server it seems very over kill for what I need to achieve, single user, small files, basic callbacks etc etc.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7394
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Building FTP Server

Post by jacque » Sun Jan 27, 2013 10:24 pm

This may be what you want:

http://www.hyperactivesw.com/cgitutorial/index.html

You'll need an older version of the LiveCode engine, plain-text CGIs don't work with the current release.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Building FTP Server

Post by Nakia » Sun Jan 27, 2013 11:06 pm

Thanks Jacque,

Looking at this though I am still convinced it is just too complex for that I need to achieve.
I think I am going to look at the sockets route for now, and just move the data over some sockets.

Note - This is for a Mobile to Desktop application where the Application needs to write and get txt files <1Mb a few times a day.
I am currently using FTP to do this and it works fine but that relies on having the FTP Server running (and setup correctly, firewalls etc) on the Desktop and this is the problem a few of my users are having..
If it i use sockets in my own desktop application (for Mac and Windows) then I figure I have complete control and can make it much simpler for the user.

Post Reply