尝试用JAVA发送大数据(超过2^16字节)时出现Websocket错误 private void getIncomingData(InputStream为,OutputStream os)引发IOException{ List bucket=new ArrayList(); while(true){ 试一试{ 列表=新的ArrayList(); int-readed; 而((readed=is.read())!=-1){ 列表。添加(已读); if(is.available()0){ //检查是最后一帧 if(checkIsFinalFrame(list.get(0.byteValue())){ this.isLastFrame=true; } System.out.println(“列表的大小[“+list.SIZE()+”]\n\n”); bucket.add((ArrayList)列表); } 打破 } } }捕获(IOE异常){ System.out.println(e.getMessage()); is.close(); os.close(); 打破 } } }
发送小于2^16的数据时,第一个字节为10000001 一切正常 但当数据超过2^16时,第一个字节是00000001 并且不再接收帧(等待字节10000001) 对于客户端,使用“var socket=new-WebSocket('ws://…);”尝试用JAVA发送大数据(超过2^16字节)时出现Websocket错误 private void getIncomingData(InputStream为,OutputStream os)引发IOException{ List bucket=new ArrayList(); while(true){ 试一试{ 列表=新的ArrayList(); int-readed; 而((readed=is.read())!=-1){ 列表。添加(已读); if(is.available()0){ //检查是最后一帧 if(checkIsFinalFrame(list.get(0.byteValue())){ this.isLastFrame=true; } System.out.println(“列表的大小[“+list.SIZE()+”]\n\n”); bucket.add((ArrayList)列表); } 打破 } } }捕获(IOE异常){ System.out.println(e.getMessage()); is.close(); os.close(); 打破 } } },java,websocket,server,Java,Websocket,Server,发送小于2^16的数据时,第一个字节为10000001 一切正常 但当数据超过2^16时,第一个字节是00000001 并且不再接收帧(等待字节10000001) 对于客户端,使用“var socket=new-WebSocket('ws://…);” 我不明白怎么了 将它们划分为块显示我可以从客户端对它们进行分块吗? private void getIncomingData(InputStream is, OutputStream os) throws IOException { Li
我不明白怎么了 将它们划分为块显示我可以从客户端对它们进行分块吗?
private void getIncomingData(InputStream is, OutputStream os) throws IOException {
List<ArrayList> bucket = new ArrayList<ArrayList>();
while (true) {
try {
List<Integer> list = new ArrayList<Integer>();
int readed;
while ((readed = is.read()) != -1) {
list.add(readed);
if (is.available() <= 0) {
// add to bucket with FRAMES
if (list.size() > 0) {
// check is final Frame
if (checkIsFinalFrame(list.get(0).byteValue())) {
this.isLastFrame = true;
}
System.out.println("SIZE OF list[ " + list.size() + " ]\n\n");
bucket.add((ArrayList) list);
}
break;
}
}
} catch (IOException e) {
System.out.println(e.getMessage());
is.close();
os.close();
break;
}
}
}