Results 1 to 3 of 3
- 06-06-2009, 01:17 AM #1
Senior Member
- Join Date
- Mar 2009
- Posts
- 552
- Rep Power
- 5
ObjectInputStream wait for readable objects
Hi all. I have a Server/Client program where they send Objects back and forth. I'm wondering if it is possible to make the ObjectInputStreams block until there is an object that can be read. Currently I get exceptions when I try to run the program because there is nothing in the stream that can be read. Is there any way to do this?
Thanks in advance,
Singing BoyoIf the above doesn't make sense to you, ignore it, but remember it - might be useful!
And if you just randomly taught yourself to program, well... you're just like me!
- 06-06-2009, 12:06 PM #2
Send a dummy object first so that the stream's headers get set up. Subsequent read() calls should then block?
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
- 06-08-2009, 03:43 AM #3
Senior Member
- Join Date
- Mar 2009
- Posts
- 552
- Rep Power
- 5
ObjectInputStream.readObject() does not block. Period. I don't think that there is anything I can do about it, other than looping endlessly around my try/catch block until I get an object... But that would just seem messy and inefficient. Hopefully I'm wrong...
If the above doesn't make sense to you, ignore it, but remember it - might be useful!
And if you just randomly taught yourself to program, well... you're just like me!
Similar Threads
-
ObjectInputStream does not initialize
By Singing Boyo in forum New To JavaReplies: 1Last Post: 06-03-2009, 08:11 AM -
Reading from ObjectInputStream
By deepthought015 in forum NetworkingReplies: 8Last Post: 04-28-2009, 05:57 PM -
Stops when opening ObjectInputStream
By Norberhuis in forum NetworkingReplies: 4Last Post: 01-09-2009, 04:19 PM -
Error while converting trace file to readable txt
By suresh in forum Forum LobbyReplies: 1Last Post: 12-04-2008, 07:31 AM -
Convertin a .DAT file into readable format
By janakiram.attuluri in forum Advanced JavaReplies: 1Last Post: 12-07-2007, 10:00 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks