File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "socket  data compression problem" Watch "socket  data compression problem" New topic
Author

socket data compression problem

bow huang
Greenhorn

Joined: Apr 28, 2004
Posts: 4
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

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

Joined: Apr 28, 2004
Posts: 4
Thanks for your reply,
I will hava a try
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: socket data compression problem