This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
send zip file across wire using client / server sockets
Posted by John on August 30, 2000 at 4:11 PM
I'm writing a simple server program which takes a zip file and tries to write its contents to the output stream of a socket.
Platform: windows NT 4.0
PROBLEM: a java.net.SocketException is thrown when I call putNextEntry of ZipOutputStream.
Here's the stack trace:
ava.net.SocketException: Connection reset by peer: socket write error
at java.net.SocketOutputStream.socketWrite(Native Method)
at java.net.SocketOutputStream.write(Unknown Source)
at java.util.zip.ZipOutputStream.writeInt(Unknown Source)
at java.util.zip.ZipOutputStream.writeLOC(Unknown Source)
at java.util.zip.ZipOutputStream.putNextEntry(Unknown Source)
Here's the code snipet from my SampleServer class:
serverSocket = new ServerSocket(4444);
clientSocket = serverSocket.accept();
zipOutputStream = new ZipOutputStream (clientSocket.getOutputStream());
//archive is my existing zip file
archive = getZipFile();
for (Enumeration e = archive.entries(); e.hasMoreElements();)
ZipEntry zipEntry = (ZipEntry) e.nextElement();
//****here's where the problem seems to lie***********
Please let me know what I'm doing wrong, and how I can fix it so I can send zip file contents across, using sockets.