Ciao a tutti ho un problema con un client che sto sviluppando per AIR.
Una volta che ho connesso anche la socket dati al server ftp, i comandi smettono di funzionare e qualsiasi comando io scriva non ricevo nessuna risposta, ne positiva ne negativa.
Sapete dirmi perchè?
codice:import flash.events.Event; import flash.events.IOErrorEvent; import flash.events.MouseEvent; import flash.events.ProgressEvent; import flash.events.SecurityErrorEvent; import flash.net.Socket; import flash.utils.Endian; protected var s:Socket; // socket comandi protected var s_dati:Socket; protected function btn_connetti_clickHandler(event:MouseEvent):void { function connesso(evt:Event):void { //label_stato.text += "Connesso!"; // ora che la socket è connessa invia user e password s.writeUTFBytes("USER ***\n"); s.writeUTFBytes("PASS ******\n"); // apre un canale dati passivo s.writeUTFBytes("PASV\n"); } function connessoDati(evt:Event):void { label_stato.text += "Socket dati connessa!"; s.writeUTFBytes("\nLIST\n\n"); VIENE IGNORATOOOO LIST } /*function riceviDati(evt:ProgressEvent):void { label_stato.text += "DATI -> "+ s_dati.readUTFBytes(evt.bytesLoaded); }*/ function erroreSicurezza(evt:SecurityErrorEvent):void { label_stato.text = "Errore nella sicurezza "+evt.text; } function progresso(evt:ProgressEvent):void { var str:String = s.readUTFBytes(evt.bytesLoaded); label_stato.text += str; var arrS:Array = str.split("\n"); for (var i:int = 0; i<arrS.length; i++) { //if(arrS[i]) //label_stato.text += "->"+arrS[i]+"\n"; var tmps:String = arrS[i].toString(); if(tmps.substr(0,3) == "227") { label_stato.text += tmps+"\n"; var IPport:String = tmps.substring( tmps.indexOf("("), tmps.indexOf(")") ); var numeri:Array = IPport.split(","); var porta:Number = 0; // numero di porta; var LSB:Number = numeri[numeri.length-1]; var MSB:Number = numeri[numeri.length-2]; //numeri[numeri.length-1] = numeri label_stato.text += "Connessione passiva\n" + MSB+ " " + LSB+"\n"; porta = (MSB *256) + LSB; //label_stato.text += "Porta: "+porta; s_dati.connect("ftp.****.it", porta); } } } function erroreIO(evt:IOErrorEvent):void { label_stato.text += "\nERRORE " + evt.text; } // crea la socket s = new Socket(); s_dati = new Socket(); // gestione eventi s.addEventListener(Event.CONNECT, connesso); s.addEventListener(ProgressEvent.SOCKET_DATA, progresso); s.addEventListener(IOErrorEvent.IO_ERROR, erroreIO); s.addEventListener(SecurityErrorEvent.SECURITY_ERROR, erroreSicurezza); s_dati.addEventListener(Event.CONNECT, connessoDati); //s_dati.addEventListener(ProgressEvent.SOCKET_DATA, riceviDati); s_dati.addEventListener(IOErrorEvent.IO_ERROR, erroreIO); s_dati.addEventListener(SecurityErrorEvent.SECURITY_ERROR, erroreSicurezza); s.connect("ftp.****.it", 21); } protected function btn_dati_clickHandler(event:MouseEvent):void { label_stato.text += tx_comandi.text+"\n"; s.writeUTFBytes(tx_comandi+"\n"); }

Rispondi quotando