- ReaperUnreal
- Feb 21, 2007
-
Trogdor is King
|
I feel like strangling Java right now, so to keep myself away from the police I will ask here. I'm no stranger to Java, on my 5th year of my 4 year comp-sci program I know it front and back. Somehow though, Sockets seem to be destroying me right now and I have no idea why. It seems that the order in which I create the input/output streams from a socket may or may not break the program. Here's what I mean,
code:// create the output and input streams
dos = new DeflaterOutputStream(client.getOutputStream(), new Deflater(Deflater.BEST_COMPRESSION));
oos = new ObjectOutputStream(dos);
// send the scene
oos.writeObject(scene);
// send the render size
oos.writeObject(renderSize);
// send the render coordinates
oos.writeObject(workPool.poll());
dos.finish();
// get the render surface
ois = new ObjectInputStream(new InflaterInputStream(client.getInputStream()));
RenderSurface rs = (RenderSurface) (ois.readObject());
// get the render coordinates
RenderCoords rc = (RenderCoords) (ois.readObject());
This works fine.
code:// create the output and input streams
dos = new DeflaterOutputStream(client.getOutputStream(), new Deflater(Deflater.BEST_COMPRESSION));
oos = new ObjectOutputStream(dos);
ois = new ObjectInputStream(new InflaterInputStream(client.getInputStream()));
// send the scene
oos.writeObject(scene);
// send the render size
oos.writeObject(renderSize);
// send the render coordinates
oos.writeObject(workPool.poll());
dos.finish();
// get the render surface
RenderSurface rs = (RenderSurface) (ois.readObject());
// get the render coordinates
RenderCoords rc = (RenderCoords) (ois.readObject());
This however hangs on the line that creates the ObjectInputStream, and I have no idea why. The java doc is of no help, so I'm hoping that someone here has encountered this before. It's becoming REALLY annoying, and I'm considering switching everything over to CORBA or JavaSpaces despite the work, just because this is being so annoying. Oh btw, this code is inside the run() method of a Runnable object.
|
#
¿
Mar 21, 2008 06:59
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
Apr 28, 2024 10:38
|
|
- ReaperUnreal
- Feb 21, 2007
-
Trogdor is King
|
Huh, how did I not see that? Thanks for the help, looks like I'll be reorganizing things. This'll be fun, having to create input and output streams inside a loop. Honestly, some times, I wish I was using C instead of Java.
|
#
¿
Mar 21, 2008 16:03
|
|