1

我的 AS3 客户端程序在发送大量消息时没有收到发送给它的所有数据。我知道不是我的服务器导致了这个问题,因为所有消息都被正确接收和发送。我的 as3 客户端只是没有收到所有发送的数据。

    private function socketData(event:ProgressEvent):void {
       while(this.socket.bytesAvailable}
          var str:String = this.socket.readUTFBytes(this.socket.bytesAvailable);
          trace(str);
       }
    }

你们中有人知道解决方案吗?

4

2 回答 2

2

今天下午我也遇到了同样的问题。最后我提出了一个解决方案:事实上,您必须像这样逐字节读取消息:

private function socketData (evt:ProgressEvent):void {
    var msg:String = ""; // create a buffer
    while (socket.bytesAvailable) { // while there is byte to read
        var byte:int = socket.readByte();
        if (byte==0) { // if we read the end byte
            trace(msg); // treat your message
            msg = ""; // free the buffer
        } else {
            msg += String.fromCharCode(byte); // else, we add the byte to our buffer
        }
    }
}

我希望这能帮到您 :)

于 2011-11-01T14:10:10.777 回答
1

问题解决了,我只需要打开路由器上的端口。

于 2012-08-11T20:20:28.203 回答