Jump to content

  • Log In with Google      Sign In   
  • Create Account

how to implement non I/O blocking


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • This topic is locked This topic is locked
2 replies to this topic

#1 YyYo   Members   -  Reputation: 137

Like
0Likes
Like

Posted 18 May 2014 - 05:32 AM

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.

 



Sponsor:

#2 slicer4ever   Crossbones+   -  Reputation: 3982

Like
0Likes
Like

Posted 18 May 2014 - 12:47 PM

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.

#3 rip-off   Moderators   -  Reputation: 8726

Like
0Likes
Like

Posted 18 May 2014 - 02:52 PM

You already have a topic about this. This question isn't sufficiently different to merit a new topic.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS