[java] Two Printwriters and Two BufferedReaders in only one socket
I´m doing a multiplayer game, and because of the nature of the game (it''s a card game, turn-based, and anyone can chat at anytime), I need two streams for each socket the player opens, one for the game operations, and another for free chat. I could create two sockets for each player, but it''s cumbersome (I think) and reduces the server capacity in a half.
Is there a way to create two streams from a single socket? :D
Thnx for your replies
Mac for productivity
Linux for development
Palm for mobility
Windows... for the Solitaire
There is no way to get two streams from a socket.
What you should do, instead, is encapsulate the chat messages in the game protocol. That''s what pretty much every game out there does already...
You must already have several kinds of move messages in the game protocol.. Just add another message which means "this next block of text (delineated by newlines, or something similar) is a chat message."
What you should do, instead, is encapsulate the chat messages in the game protocol. That''s what pretty much every game out there does already...
You must already have several kinds of move messages in the game protocol.. Just add another message which means "this next block of text (delineated by newlines, or something similar) is a chat message."
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement