Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

StreamCorruptionException

 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey everyone,

I am working on a small chat program for a class I am taking and am running into a lot of stream issues which I hope someone can give me some ideas how to fix.

Layout:
The basic setup of my program is the server-client model, I have a multi-threaded server which clients can connect to. When A client connects a ThreadHandler is spawned to hold the interaction between a single client and the server. Both the client and the ThreadHandler have an ObjectOutputStream and an ObjectInputStream object that are instantiated in their constructors.

Problem:
I can call some operations without running into issues but when I call some I get this error


I believe that one of the streams is writing its header twice but I dont really know why. Any ideas on this would be great!

Thanks,
Hunter
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But it's your program that's responsible for what the streams are doing. So your best bet would be to look at your code. (In fact that's always the best bet the first time you encounter a problem. It's almost always your fault, it's extremely rare that you're going to find a bug in the API.)
 
Hunter McMillen
Ranch Hand
Posts: 492
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry I wasn't trying to imply that there is a bug in the API, I know most assuredly this is my fault I just can't seem to find the problem. And was looking for suggestions on where to look, I'm unsure how the streams could be corrupted if they are only instantiated once and used for the whole interaction between the server and the client.

Hunter
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic