English 中文(简体)
2. 难以使用闪电/Adobe Air 2.0 Sockets
原标题:Difficulty using Flash/Adobe Air 2.0 Sockets

I m试图向原始数据表(大约22种甲基溴)撰写一些数据。 情况如下:

  1. Open local file
  2. Read a chunk of bytes.
  3. Write it to the Socket
  4. Repeat 2 & 3 until the end of the file.

现在的问题是,我的法典(下文)没有移交完整的档案。 它可能把22个甲基溴中的3个转让给我的测试档案。 但是,这些追踪是完整的,显示完整的数据。 我怀疑,在完成目前的工作之前,也许会开始撰写下一个空白。

while(fs.bytesAvailable > 0){
    var readAmount = (fs.bytesAvailable < socketBufferSize) ? fs.bytesAvailable : socketBufferSize;
    seq++;
    air.trace(">"+seq+" WritePacket "+readAmount+" "+fs.position+" "+fs.bytesAvailable);
    fs.readBytes(bytes, 0, readAmount);
    air.trace(bytes.length);
    socket2.writeBytes(bytes, 0, bytes.length);
    socket2.flush();
}
fs.close();
socket2.close();

首先是I> 。 我想知道我是否是这样。

在书写间隔之间插入一个强制性的延迟,可确保档案完全转入下文各页。 然而,这不是可以接受的解决办法。 我愿知道,我是否应该支持某些活动,或者是否需要以不同的方式做任何事情。 另一端的服务器是FileZilla FTP服务器。

var sendData = function (){
    if(fs.bytesAvailable > 0){
    var readAmount = (fs.bytesAvailable < socketBufferSize) ? fs.bytesAvailable : socketBufferSize;
    seq++;
    air.trace(">"+seq+" WritePacket "+readAmount+" "+fs.position+" "+fs.bytesAvailable);
    fs.readBytes(bytes, 0, readAmount);
    air.trace(bytes.length);
    socket2.writeBytes(bytes, 0, bytes.length);
    socket2.flush();
    }
    else{
        air.trace("Closing Connection");
        fs.close();
        socket2.close();
    }
}
var interval = setInterval(sendData, 100);

增 编

问题回答

由于AIR有残酷的袖珍业务,需要修改服务器,让客户知道何时收到所发送的所有数据(通过另一个TCP控制表)。 当然,客户需要转播其最初发送的数据。

当时,在数据完全写成时,一米等待着一件活ocket的事件。

第一个想法是在每个字后推迟。 然而,如果实际关系良好,由于拖延,移交的时间更长。 在连接缓慢的情况下,拖延并非总是足够,因此某些数据仍然可以丢失:

The only one solution that i ve found is not really proper but works. I m using proftpd as FTP server with a MOD that i ve written that allows a new FTP command : FILESIZE. This command give the size of a filepath in octets.

Then, in flex, i ve 2 sockets opened : one for transmitting the data, one to get the filesize. After each call of write() on the first socket, i get the size of the file using FILESIZE on the second socket.

问题的另一个方面是,转让需要很多时间,因为FTP呼吁FLESIZE(:/)但转让更为可靠。

This is the kind of problem that will probably move from Flex to Java. Alomost two years that is problem is posted on Adobe Bug pages, and... nothing... Is there a way to add this feature in the core of flex ? I don t think so, flash is not open source...





相关问题
Disable button tooltip in AS3

I want to disable the tooltip on certain buttons. The tooltip manager seems to be an all or nothing solution. Is it possible to disable the tooltip for just one or two buttons?

Multiple Remote call made simultenously

I was making multiple remote calls and they are done sequentially and when I am getting a result event back it s triggering calls to all the methods with ResultEvent as an argument . I am supposed to ...

Attaching a property to an event in Flex/AS3

I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...

Clearing RSL in Cache

I have built a flex application which has a "main" project and it is assosciated with a few RSL s which are loaded and cached once i run my "main" application. The problem i am facing is that the ...

What s a good way of deserializing data into mock objects?

I m writing a mock backend service for my flex application. Because I will likely need to add/edit/modify the mock data over time, I d prefer not to generate the data in code like this: var mockData =...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...

热门标签