Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

socket data compression problem

 
bow huang
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
dear everybody,
i hava a problem in socket data compression:
client:
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);

server:
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
The app blocked when run to readLong() and readInt(),what's the problem?
 
David Weitzman
Ranch Hand
Posts: 1365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try calling output.flush() before attempting to read input.
 
bow huang
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply,
I will hava a try
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic