Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sockets 使用Deflate压缩数据查找块结束标记Flash ByteArray_Sockets_Apache Flex_Websocket_Bytearray_Deflate - Fatal编程技术网

Sockets 使用Deflate压缩数据查找块结束标记Flash ByteArray

Sockets 使用Deflate压缩数据查找块结束标记Flash ByteArray,sockets,apache-flex,websocket,bytearray,deflate,Sockets,Apache Flex,Websocket,Bytearray,Deflate,我有一些数据通过web套接字发送到flash客户端。该数据在发送到客户机之前使用Java Deflate类进行压缩 我得到一份工作 错误#2058:解压缩数据时出错 当线路上的数据很大时,调用byteArray的deflate方法 对服务器上的代码进行放气(Scala): 发送到客户端: def sendToClient(message:String) { println("original message length: " + message.length) val

我有一些数据通过web套接字发送到flash客户端。该数据在发送到客户机之前使用Java Deflate类进行压缩

我得到一份工作

错误#2058:解压缩数据时出错

当线路上的数据很大时,调用byteArray的deflate方法

对服务器上的代码进行放气(Scala):

发送到客户端:

def sendToClient(message:String) {
      println("original message length: " + message.length)
      val compressed = deflate(message)
      //wrap the compressed data in base64 encoded string because of a requirement for this on the client          
      val toClient = Base64.encodeBase64String(compressed)
      clientConnection.sendMessage(toClient)
    }
客户:

//read the data into the ByteArray
while(socket.bytesAvaialble > 4) {
    //unwrap base64 encoded stuff
    myByteArray[position] = socket.readUnsignedByte();
}

//inflate the data in the ByteArray
myByteArray.inflate();
当websocket上的数据很大时,调用充气失败,因为并非所有数据都在那里。在调用充气()之前,我想弄清楚如何确保所有数据都在那里

根据(第9页),我应该寻找一个块头来确定所有压缩内容何时到达


如何使用ByteArray API查找该标头?

找到放气流末端的唯一方法是将其充气。例如,通过简单地查找某些位或字节模式,结果并不明显。deflate流中的所有表和代码都需要按顺序解码,直到遇到结束


我不能代表您正在使用的API,但通常zlib的接口允许一次向充气对象提供一段放气流。充气器将在压缩数据结束时告诉您,在放气流结束后,您将得到未使用的字节。

感谢您的响应。我更新了这个问题,使之更具解释性。我在deflate调用中使用了nowrapper参数(请参阅服务器附加的服务器代码)。我看不到您在哪里解码Base64编码。另外,这也不能是您实际的客户机代码,因为您拼错了“Available”。
//read the data into the ByteArray
while(socket.bytesAvaialble > 4) {
    //unwrap base64 encoded stuff
    myByteArray[position] = socket.readUnsignedByte();
}

//inflate the data in the ByteArray
myByteArray.inflate();