socket数据压缩传输问题

jerryhuang10 2004-04-30 09:46:55
客户端:
socket = new Socket(host,4000);

ZipOutputStream zipout = new ZipOutputStream(socket.getOutputStream());
zipout.putNextEntry(new ZipEntry("a.zip"));

DataOutputStream output = new DataOutputStream(zipout);
DataInputStream input = new DataInputStream(socket.getInputStream());

output.writeLong(10000);
long clientNumber = input.readLong();//1234
output.writeInt(222);


服务器端:
ServerSocket serversocket = new ServerSocket(4000);
Socket client = serversocket.accept();
ZipInputStream zipin = new ZipInputStream(client.getInputStream());
zipin.getNextEntry();

input = new DataInputStream(zipin);
output = new DataOutputStream(client.getOutputStream());

output.writeInt(1234);
long magicNumber = input.readLong();//10000
int intnumber = input.readInt();//222

请问像上面这样用socket压缩数据进行传输可以吗?
好像在readLong()和readInt()时碰到了问题,程序被Block了,
请教高手,怎么样在socket压缩数据时用DataInputStream()和DataOutputStream()?
...全文
117 2 点赞 打赏 收藏 举报
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
jerryhuang10 2004-04-30
急啊
  • 打赏
  • 举报
回复
jerryhuang10 2004-04-30
哪位高手re 一下啊
  • 打赏
  • 举报
回复
相关推荐
发帖
Java SE
加入

6.2w+

社区成员

Java 2 Standard Edition
申请成为版主
帖子事件
创建了帖子
2004-04-30 09:46
社区公告
暂无公告