Archived

This topic is now archived and is closed to further replies.

[java] Two Printwriters and Two BufferedReaders in only one socket

This topic is 5573 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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."

Share this post


Link to post
Share on other sites