Re: Network protocol for Expert QotW #23
"Rick Measham" <[email protected]>
| Newsgroups | gmane.comp.lang.perl.qotw.discuss |
|---|---|
| Message-ID | <[email protected]> |
> Bruce J Keeler <[email protected]> writes: > > > Why not just use one port and have each connection tell the server what > > it is? When I read the original protocol you proposed, I thought this > > bit: > > > > PLAYER1 [Comment] > > PLAYER2 [Comment] > > SPECTATOR [Comment] > > > > was client -> server; I only now realized it wasn't upon re-reading. > > But it could be. On Fri, 10 Sep 2004 00:16:57 -0400, Daniel Martin replies: > I suppose, though in that case we also need to define server responses > for "request successful" and "someone else is already PLAYER1", though > I suppose we could always just have the program ask and the server > respond with the result, but that gets messy. I'd prefer to leave it as a single port. I think a single conversation would be a nicer way to work, but I'm open to argument. Here's several examples of my thoughts on the conversation. Please feel free to comment. I'll embed this in stone in about 24 hours. '>' is server -> client. '<' is client -> server: <HELLO >GAME NOPLAYER1 NOPLAYER2 <PLAYER1 Rick Measham >PLAYER1 Rick Measham >INFO PLAYER1 Rick Measham ... and so on ... <HELLO >GAME NOPLAYER2 <SPECTATOR Daniel Martin >SPECTATOR Daniel Martin >INFO PLAYER1 Rick Measham ... and so on ... <HELLO >GAME NOPLAYER2 <PLAYER2 Bruce Keeler >PLAYER2 Bruce Keeler >INFO PLAYER1 Rick Measham >INFO PLAYER2 Bruce Keeler ... and so on ... <HELLO >GAME; <SPECTATOR MJD >SPECTATOR MDJ >INFO PLAYER1 Rick Measham >INFO PLAYER2 Bruce Keeler <INFO SPECTATORS >INFO SPECTATORS Daniel Martin;MJD ... and so on ... In the above MJD conversation, Mark's client has asked for the list of spectators. Here's the same three conversations in chronological order (with more lines too!) Rick Measham | Daniel Martin | Bruce Keeler | MJD | ----------------+-------------------+-------------------+-------------------+ <HELLO | | | | >GAME J20 NOPLAYER1 NOPLAYER2 | | | <PLAYER1 Rick Measham | | | >PLAYER1 Rick Measham | | | >INFO PLAYER1 Rick Measham | | | |<HELLO | | | |>GAME J20 NOPLAYER2| | | |<SPECTATOR Daniel Martin | | |>SPECTATOR Daniel Martin | | >INFO SPECTATORS +Daniel Martin | | | |>INFO PLAYER1 Rick Measham | | | |<HELLO | | | |>GAME J20 NOPLAYER2| | | |<PLAYER2 Bruce Keeler | | |>PLAYER2 Bruce Keeler | | |>INFO PLAYER1 Rick Measham | | |>INFO SPECTATORS Daniel Martin | >INFO PLAYER2 Bruce Keeler | | | |>INFO PLAYER2 Bruce Keeler | | | |>INFO PLAYER2 Bruce Keeler | <STARTGAME | | | | |>CHOOSE #+& 1 | | | |<CHOOSE + 1 | | | >DIFF E20+ | | | | |>DIFF E20+ | | | | |>DIFF E20+ | | | | |<HELLO | | | |>GAME J20 | | | |<SPECTATOR MJD | | | |>SPECTATOR MJD | >INFO SPECTATORS +MJD | | | |>INFO SPECTATORS +MJD | | | |>INFO SPECTATORS +MJD | | | |<INFO SPECTATORS | | | |>INFO SPECTATORS Daniel Martin;MJD If that hasn't come out for you, take a look at http://rickm.printaform.com.au/qotw/23/ conversation.txt > Also, someone posted earlier about sequence numbers on CHOOSE commands > - those would be nice, but I don't think that the numbers should be > optional. Either we decide to use sequence numbers or we don't. INFO > is the space for optional stuff. I agree. Sequence numbers are an excellent way to avoid a cheating PLAYER2 client. Cheers! Rick Measham