Article View: borland.public.jbuilder.java.api
Article #2992Re: ObjectStreams over Compressed Sockets
From: Regis Eloi
Date: Wed, 17 Jun 1998 00:00
Date: Wed, 17 Jun 1998 00:00
47 lines
2083 bytes
2083 bytes
William Yu wrote:
> Ok...it's taken me several days to figure how to send/receive objects
> over compressed sockets. My code is roughly as follows:
>
> Reader:
>
> zip_in = new ZipInputStream(socket.getInputStream());
> zip_in.getNextEntry();
> obj_in = new ObjectInputStream(zip_in);
> zip_in.closeEntry();
>
> zip_in.getNextEntry();
> myobj = (myObject)obj_in.readObject();
> zip_in.closeEntry();
>
> Writer:
>
> int zip_index = 0;
>
> zip_out = new ZipOutputStream(socket.getOutputStream());
> zip_out.putNextEntry(new ZipEntry("open"));
> obj_out = new ObjectOutputStream(zip_out);
> zip_out.closeEntry();
>
> zip_out.putNextentry(new ZipEntry("data" + (zip_index++));
> obj_out.writeObject(myobj);
> zip_out.closeEntry();
>
> The above works great -- except for one issue. If the compression buffer
> is not filled, objects sit in the write queue. Any insight on the next
> logical step?
I think you have to call the flush method on your streams.
Something like:
zip_out.flush();
Hope that helps.
Regis
--
________________________________________________________________________
Regis Eloi mailto:R.Eloi@dcs.hull.ac.uk
The University of Hull (England) - Department of Computer Science
Institut d'Informatique d'Entreprise (France)
My CV is on the Web at http://www-eleves.iie.cnam.fr/eloi/cv_en.html
________________________________________________________________________
Technical Details
Message-ID:
<35878ED5.716AAD75@dcs.hull.ac.uk>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<3586F17B.47E70646@Bigfoot.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1089d0,c0a4ae4801217f6f,start X-Google-Attributes: gid1089d0,public From: Regis Eloi <R.Eloi@dcs.hull.ac.uk> Subject: Re: ObjectStreams over Compressed Sockets Date: 1998/06/17 Message-ID: <35878ED5.716AAD75@dcs.hull.ac.uk> X-Deja-AN: 363466732 Content-Transfer-Encoding: 7bit References: <3586F17B.47E70646@Bigfoot.com> Mime-Version: 1.0 Reply-To: R.Eloi@dcs.hull.ac.uk To: William Yu <William_Yu@Bigfoot.com> Content-Type: text/plain; charset=us-ascii Organization: University of Hull Newsgroups: borland.public.jbuilder.java.api