Blocking ObjectInputStream without any exception :-(

Hi y’all.

In my run() method (from a class that implements runnable ;)), I use this:
“ois=new ObjectInputStream(so.getInputStream())”
where so is a socket :wink:

The problem is: when executing this code, the applications blocks without throwing any exception, and I don’t know how to solve that problem!
The same code with ObjectOutputStream works, :-\

Any idea?

Thanks!

You have to flush the outputstream, to force the bytes to be sent (not buffered). Then the inputstream will receive the bytes without further blocking.

Also take care where you are try {} catch{} your exception. If you are doing it in the thread that CREATES the spun-off thread (the one that actually runs run() ) then you’ll never catch the exception. Exceptions are bubbled up in the same context of the thread that is running it. So, you could be getting an exception, just never seeing it.

-Chris

Thanks for your help guys, my network is OK at a local level, I’m now facing an other problem…

I want to extend my network to the internet, how does it work? what should I use?

Any advice would be much appreciated! :smiley:

Thanks a lot!

You can just use the same old thing for internet networking, just connect to ips or domains instead. If you wanted to make an app that could automatically link people together (like GameSpy or something), you would need to have a server running constantly at some address (let’s just say mygameserver.com for now) that your game automatically connects to when looking for internet games. The app running on this server saves a person’s ip automatically when they log in and similarly gets rid of it when logging off, then displays a list of the ips.

Perhaps add in the ability to double click an ip to form a connection with it and you’re good to go. Your server app can then pass this ip on to the actual game, which you plug in to your Socket, just like on a local level.

If you already understand sockets on a local level, it’s really very simple to go over the whole internet. And you don’t even need to make a server of any kind if you don’t want, you could just have people figure out ips on their own.

Good luck, I hope that made sense to you.

Don’t worry, it makes sense!

Thanks for advising me, my network seems to work on the internet.