File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes socket  data compression problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "socket  data compression problem" Watch "socket  data compression problem" New topic

socket data compression problem

bow huang

Joined: Apr 28, 2004
Posts: 4
dear everybody,
i hava a problem in socket data compression:
socket = new Socket(host,4000);
ZipOutputStream zipout = new ZipOutputStream(socket.getOutputStream());
zipout.putNextEntry(new ZipEntry(""));
DataOutputStream output = new DataOutputStream(zipout);
DataInputStream input = new DataInputStream(socket.getInputStream());
long clientNumber = input.readLong();//1234

ServerSocket serversocket = new ServerSocket(4000);
Socket client = serversocket.accept();
ZipInputStream zipin = new ZipInputStream(client.getInputStream());
input = new DataInputStream(zipin);
output = new DataOutputStream(client.getOutputStream());
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

Joined: Jul 27, 2001
Posts: 1365
Try calling output.flush() before attempting to read input.
bow huang

Joined: Apr 28, 2004
Posts: 4
Thanks for your reply,
I will hava a try
It is sorta covered in the JavaRanch Style Guide.
subject: socket data compression problem