The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
August 2000

Advertisement

Advertisement

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 Artima Forums.

Message:

send zip file across wire using client / server sockets

Posted by John on August 30, 2000 at 4:11 PM

Hi,
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
jdk 1.2.2-006

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)
at classloader.SampleServer.invokeServer(SampleServer.java:81)
at classloader.SampleServer.main(SampleServer.java:54)

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***********
zipOutputStream.putNextEntry(zipEntry);
}

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.

Thanks,
John






Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us