Advertisement

how to implement non I/O blocking

Started by May 18, 2014 11:32 AM
1 comment, last by rip-off 10 years, 6 months ago

Hi...

I newbie to the forum and to multiplayer game.

I started to implement a simple multiplayer game, using Java, and I have a question.

When 2 clients login to server, a new game is establish for them.

each player, in his turn, make a move and inform the server(which authenticate and send to opponent).

when one player is playing, the other is waiting for the server to inform him that now its his turn(server send 'TURN' message)

The problem is that the player is waiting for the server by readLine() method which block the main thread.

I am planning to implement a Chat so the players could communicate each other, and if the main thread is block I wont be able to do so.

Should I need to implement 2 thread for each player: one for reading and one for writing, so the application wont block?

Any advice will appreciated.

Thx.

seriously mate: http://beej.us/guide/bgnet/output/html/multipage/advanced.html#select READ IT.

Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.
Advertisement
You already have a topic about this. This question isn't sufficiently different to merit a new topic.

This topic is closed to new replies.

Advertisement