Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

how to implement non I/O blocking

4: Adsense

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   

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.

 



#2 slicer4ever   GDNet+   

6660
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   

10890
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.