FlexFTP - FTP Client in Flex using flash.net.Socket
DIGG IT!
16
Comments
Published
Friday, May 11, 2007
at
8:43 AM
.
Binary Sockets are so cool, you can connect to any type of TCP/IP server, yes any even FTP! I could not find the developers name (got it! Mali!!!) but Maliboo.pl has posted source for an FTP client in Apollo and client classes in AS3.
Project Source
flash.net.Socket
Great Work Mali!
Ted :)

"mali" is shortcut from maliboo: my nickname ;)
My full name is Maciej Maliborski.
Maciej great work! Ted :)
Thanks ;)
But the main problem with FTP component/library/whatever ;) is SERIOUSY lack of functionality in Socket class. You can't get status/amount of flushing (sending data) process:
http://tech.groups.yahoo.com/group/flexcoders/message/72018
It major PITA.
Maliboo,
flash.net.Socket is intentionally simple. It is very low level metal there directly against the TCP/IP layers within Flash Player.
The key is realizing that you can and "should" build higher level APIs around it to be productive. This was done in Flex Data Services to neutralize the transport layers.
I was thinking that it was ripe for a model like Twisted where you can defer execution until packets/blocks are complete. Right now you have to handle all the data exchange and byte-blockery yourself which is labor-intensive.
There is also a desire to program on a Syncronous manner. This became very clear when Darron had issues with FlashVNC.
A higher level socket library is needed. :)
My 2 cents,
Ted :)
As Ted said, I had some major problems with FVNC initially. Programming sockets in a synchronous manner is a much easier mental model, and I was banging my head against a wall trying to figure out the best way to deal with the asynchronous nature of the flash.net.Socket class.
FVNC now has a solution in place that takes advantage of the asynchronicity nature of the Socket class. It's a little harder to wrap your head around than a simple readyByte(); readInt(); style of coding, but in the end it turned out extremely well, and I'm happy with the current solution.
Take a look at RFBParser from http://svn1.cvsdude.com/osflash/fvnc/trunk/fvnc/src/fvnc/rfb/ and drill down from there. Basically, we build a parse tree as data becomes available, and when we have enough data to complete a message, we process it. Works great!
I understand that. But knowing output buffer status is (for me) crucial (and low level ;)) like knowing input buffer with Socket::bytesAvailable. There's no such property like outputBytesAvailable. Any kind of really simple info:
- outputBytesAvailable:int (is output buffer clear and ready to fill again)
- flush():Boolean (when flushing empty output buffer returns false)
- flush():Throw Error (when flushing empty buffer)
- flush() are ALWAYS synchronous when sending less than 1024b (or even 8bytes ;))
Any simple (true/false value) thing would be VERY helpful. Especially with very large files sending. And I can bet, that this would be very painful with incoming Apollo apps for interchanging binary data over binary Sockets with simple back-end.
Comparing this to input: it's like getting progress event only when whole data is available (like in XMLSocket)
@Darron:
Incoming data with ProgressEvent aren't problem here. Main problem is lack of info about outgoing data.
In FTP server context: when you start uploading process, you can fill+flush buffer in intervals, but you don't get ANY info about progress from server, until FTP doesn't return you some message that the uploading process is ended.
You fill buffer in datachunks, flush it, close socket in AS via Socket::close(), but physically this socket isnt't closed- data are still sending from your computer to FTP. It seems that REALLY socket closing is deferred until it's realu flushed, on really, really low player level.
Try to play with pl.maliboo.ftp.invokers::UploadInv with some "large" (100kB+) files. In VNC you've probably send small amount of data form client to VNC server, so it's progress may be neglected. In FTP when sending file I can only show undetermined progress bar :(
Of course, there are some workarounds, but only workarounds:(
Im developing http://asql.mooska.pl
and Ive got the same problem. When trying to insert something bigger, i.e. into blob field (image, whatever) only response I get is after whole process. No way I can get any progress event, while uploading, wich is quite annoying.
Need some enhanced Socket class :)
Here are a couple of threads on apollocoders with a similar focus. I would love to see an advanced library for socket class.
Seems there was a lot of talk about ftp clients when flex 2.0 was first coming out, but there hasn't been much released since.
http://tech.groups.yahoo.com/group/apollocoders/message/507
http://tech.groups.yahoo.com/group/apollocoders/message/623
Hi, this is an impressive tool. However, Its just a proof of ability. If the tool could be a website component to allow the upload of files via ftp, integrated into a web page. Now that would be something.
However, I would imagine you would have done this, and that its probably not possible due to Web page sand boxing.
If it is, I think it would be a very well received app. I would love it for some stuff I am working on.
Could any knowledgeable Flex/AS3 developer shed some light about this possibility please.
James
Is there a way to upload a file using this technique from web browser? I'm searching a method to upload very large files (2-3 GB) with progress bar using only web browser.
Hey am using Flex 3...I'm not able to open this project...the error message i get is
"This application cannot be run.(Error: this application requires a version of the Adobe Intergrated Runtime(AIR) which is no longer supported.Please contact the application author for updated version.)"
Please help...Thanx in advance....
Did anyone get this working for Flex 3? if so please let me know, mr5080@comcast.net
thanks!
line #57 of FTPFile.as is wrong
line reads : var name:String = fields[8];
should be :
var name:String="";for( var i:int = 8; i < fields.length; i++ ) name+= (fields[i]+((i!=fields.length-1)?" ":""));
hello there.
I am trying to get this code working but keep getting an IO Error when the app is redirected the passive port.
I haven't yet been able to debug why its getting the IO Error, and am wondering if anyone else saw this same behavior?
thanks!
Dustin
when library try to open passive mode connection using another socket its throwing error-:Data connection already open.
I am unable to correct it. can anybody suggest me what's wrong
I havent looked at any of the code, but I know when using sockets in flash there is documentaiton that talks about denying use of ports below 1027.
FTP is by default port 21...right? Could this be whats giving many people problems