I search about this a lot on google but I didn't got anything which can be useful for me. Adobe Flex Socket reference (which doesn't even communicate about #2031 error message). I have also moved to perform FTP disk with the maliboo FTP lib but it seems the same as stated before.
Code:
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical" initialize="init()">
<mx:Script>
<![CDATA[
private var sCmd:Socket
private var sData:Socket
private function init():void{
sCmd=new Socket("xx.xx.xx.xx",21);
sCmd.addEventListener(ProgressEvent.SOCKET_DATA,commandResponse)
sCmd.addEventListener(IOErrorEvent.IO_ERROR, commandError);
sCmd.writeUTFBytes("USER xxxxxx\n");
sCmd.flush();
sCmd.writeUTFBytes("PASS xxxxxxx\n");
sCmd.flush();
sCmd.writeUTFBytes("CWD /mydirectory/\n");
sCmd.flush();
sCmd.writeUTFBytes("PASV\n");
sCmd.flush();
}
private function commandResponse(e:ProgressEvent):void{
var command_resp:String=sCmd.readUTFBytes(sCommand.bytesAvailable)
if(command_resp.indexOf("227")>-1){
var temp:String = command_resp.substring(command_resp.indexOf("(")+1,command_resp.indexOf(")"));
var data_channel_temp:Array = temp.split(",");
var data_channel_ip:String=data_channel_temp.slice(0,4).join('.')
var data_channel_port:int=parseInt(data_channel_temp[4])*256+parseInt(data_channel_ temp[5])
trace(data_channel_ip+" "+data_channel_port)
sData=new Socket(data_channel_ip,data_channel_port)
sData.addEventListener(ProgressEvent.SOCKET_DATA,dataResponse)
sData.addEventListener(IOErrorEvent.IO_ERROR, dataError);
}
trace("command "+command_resp)
}
private function commandError(e:IOErrorEvent):void{
trace("command -> "+e.text)
}
private function dataResponse(e:ProgressEvent):void{
trace('data '+e)
}
private function dataError(e:IOErrorEvent):void{
trace('data error ' +e)
}
]]>
</mx:Script>
</mx:WindowedApplication>
Bookmarks