Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / FTP client with AGK? why not!

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 1st Mar 2024 04:15 Edited at: 6th Mar 2024 00:55
Far from complete, but it shows it's possible. I think I'm gonna try to build a full GUI just for the sake of it. What the code below can do is provide a working framework for using FTP. It will connect, authenticate, establish the secondary data connection, then finally retrieve a directory listing of files. This uses passive mode (as opposed to active), which I chose to do so because it's simpler to implement and test because the client requests connection details from the server rather than telling the server how to connect to the client. Also, there is no TLS here, so passwords are sent in plain text. Because of that, I would not recommended using this in any production application where the connection relies on your own personal credentials as it's simple to intercept. So if anyone would like to attempt to implement TLS......
One last note, the server address has to be an IP and not "ftp.myserver.com".

Commands:
ftp_connect( ip, user, pass, logging[0,1] )
ftp_SetLogFile( path )
ftp_disconnect()
ftp_setLocalDir( path )
ftp_listener()
ftp_list()
ftp_getFileList()
ftp_sendFile( filename )
ftp_getFile( filename )
ftp_SetDir( path )



ftp.agc
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda
Pixel-Perfect Collision

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 1st Mar 2024 22:42 Edited at: 1st Mar 2024 22:43
I just added an FTP server to my virtual machine to test your code and i must say it works fine ^^
Are you working with github i'd like to add some easy commands like PWD to get the current deirectory or CWD to change the directory if you didn't add them already ?
Yeshu777
4
Years of Service
User Offline
Joined: 26th Feb 2020
Location: Cardiff ( Caerdydd ), Wales ( Cymru ), UK
Posted: 2nd Mar 2024 02:54
Great work, definitely of interest.

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 2nd Mar 2024 18:04
I’ll add more commands in. I haven’t added it to GitHub but I can. I’ll want to restructure the code first, you can probably see why. It started as just a proof of concept. I got it to download an image file after having to put it in binary mode.
I’m actually surprised how hard it’s been to find decent documentation on the protocol.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda
Pixel-Perfect Collision

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

janbo
16
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 2nd Mar 2024 20:15 Edited at: 2nd Mar 2024 20:28
I like this one but it's mostly in German
https://www.elektronik-kompendium.de/sites/net/0902241.htm
Scroll down a bit and you'll find all the commands and satus codes.
Yeshu777
4
Years of Service
User Offline
Joined: 26th Feb 2020
Location: Cardiff ( Caerdydd ), Wales ( Cymru ), UK
Posted: 5th Mar 2024 09:49
Hi Phaelax,

I guesss this won't work on SFTP servers?

I know libCurlSSL does add this functionality, in comparison to libCurl.

Yeshu777
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 5th Mar 2024 16:01
that is correct. I wouldn't say it's impossible to implement, but writing your own SSL library in tier 1 would be quite challenging.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda
Pixel-Perfect Collision

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Yeshu777
4
Years of Service
User Offline
Joined: 26th Feb 2020
Location: Cardiff ( Caerdydd ), Wales ( Cymru ), UK
Posted: 5th Mar 2024 20:23
Hi Phaelax,

In the end I just changed hosts to one that supported FTP also.. your code works a charm.

I had a play with changing directories, listing the contents..

How easy would it be to upload / download a simple "report.txt" file?

I've done all of this before using Visual Studio - albeit some years ago.

Might be able to create a Plugin with the C++ code I guess.

Yeshu777
Yeshu777
4
Years of Service
User Offline
Joined: 26th Feb 2020
Location: Cardiff ( Caerdydd ), Wales ( Cymru ), UK
Posted: 5th Mar 2024 23:33
Also, which you've probably already seen

FTP Commands:

https://en.wikipedia.org/wiki/List_of_FTP_commands

FTP Respsonse Codes:

https://en.wikipedia.org/wiki/List_of_FTP_server_return_codes

Yeshu777
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 5th Mar 2024 23:48 Edited at: 6th Mar 2024 00:00
I've been working on it, half the time figuring out how the sockets all worked the other with organizing everything into an easy library. I've updated my first post to the latest code and command set.
I haven't added directory changes yet, that'll be next. But you can upload and download files and get a directory listing. I've tested with a 120mb file.

Here's an example using the library above, even if somewhat of a sloppy presentation. The bandwidth calculation is only an estimate because of the file size it's based on. You can get a response like: "150 48.1 kbytes to download" when the exact size is 49,208. Plus, your frame rate also will affect this number :p


Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda
Pixel-Perfect Collision

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Mar 2024 00:37 Edited at: 6th Mar 2024 00:56
well crap, I swear everything was working a moment ago, but now file listing isn't working...

*edit* ok, fixed it and added ftp_setDir()
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda
Pixel-Perfect Collision

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Yeshu777
4
Years of Service
User Offline
Joined: 26th Feb 2020
Location: Cardiff ( Caerdydd ), Wales ( Cymru ), UK
Posted: 6th Mar 2024 19:20
Hey Phaelax,

This works brilliantly - great work!

Yeshu777
Yeshu777
4
Years of Service
User Offline
Joined: 26th Feb 2020
Location: Cardiff ( Caerdydd ), Wales ( Cymru ), UK
Posted: 14th Mar 2024 20:45 Edited at: 14th Mar 2024 22:04
Hey Phaelax,

Created the following App using your ftp functions..



Yeshu777

Attachments

Login to view attachments
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 15th Mar 2024 21:40 Edited at: 15th Mar 2024 21:42
You got that done quicker than I have! I'm working on a full client

Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda
Pixel-Perfect Collision

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Attachments

Login to view attachments
Yeshu777
4
Years of Service
User Offline
Joined: 26th Feb 2020
Location: Cardiff ( Caerdydd ), Wales ( Cymru ), UK
Posted: 15th Mar 2024 22:06 Edited at: 15th Mar 2024 22:09
Hey Phaelax,

Great work!!..

One problem I'm having is when the user or server timeout disconnects, I can't re-connect the socket.

The CONNECT button has your ftp_connect function attached to it, but doesn't seem to like the second attempt

See attached..

Any clues?

Yeshu777

Attachments

Login to view attachments
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 10th Apr 2024 19:17
Sounds like something needs to be reinitialized. The data connection is always recreated with each action, but the command connection stays open. If that gets disconnected from the other side, it would need to be recreated and it's likely I don't refresh something on multiple connection attempts. It's been a couple weeks since I've worked on this.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda
Pixel-Perfect Collision

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Login to post a reply

Server time is: 2024-11-21 09:48:14
Your offset time is: 2024-11-21 09:48:14