ToDo List for Monopoly

We could implement this in a connection-oriented or connectionless way. Connectionless implies more overhead - we have to open and close sockets frequently, but I like the idea of being able to update my IP address; with a BT ADSL line, my IP address may change from time to time, also with dialup if I lose my connection and reestablish it. In this case, I could email one of the players, or maybe even connect to the existing game, using a key to identify myself. Other players could then update what my address is, and continue as normal. This kind of thing was a pain playing Age of Empires over the net....
Packet structure:
"%d %d %d %s"

So when receiving packets, we get:
res=recv(yoursocket, buf, 200, flags);
then do a sscanf() on buf:
sscanf("%d %d %d %20s", pkttype, index, val, strval);
	case PLAYER:	player=val; break;
	case BOARD : 	Board[index]=val; break;
	etc etc etc

When sending a packet, we do:
sprintf(buf, "%d %d %d %20s", BOARD, 3, 2, "unused");
res=send(mysocket, buf, strlen(buf), flags);

Thoughts having done the start-game network code:
We have a problem here; trying to play with three players on the same machine, how do we tell the difference between them?!! Everybody listens on port 6010, the master is waiting for connections, and doesn't know what to do about other incoming connections!
Of course, if we give in and use connection-oriented messaging, and keep the connections open throughout the game, we don't have this problem. But then we are more dependant on the server staying in the game.

What we could do, is make a note of our outgoing socket number when we first send our name to the server, then always make a point of sending from that port number. But we can't guarantee that the port will always be available, of course, so that won't work!

So what I suppose we should do, is when we send our "join" packet, not close the connection, meaning that we are now hogging the connection until we've finished talking to the server. Everybody else can just queue until we're free. That deals with the starting situation. But we'd still have the same problem during the game - so every player must identify themselves by sending a ("%d", MyPlayerNum) at the start of every packet. Of course, you don't know your playernum until you've negotiated the start!

Looking again, we've still no way of forcing one client to get the packet and not another. We are going to have to use different ports for each user. The master must be on a well-known port, so that the others can establish the initial connection (I suppose we could work like telnet and accept a port number on the command line...). The users send in their desired port number along with their name... These are all then broadcast before the start of the game.

This is now working. Changed the syntax: Master starts as "./monopoly Myname", the rest start as "./monopoly Myname Myport"


src/monopoly/c2 tree: connection-oriented

All connect to "master" on port 6010 in order of joining (as per now)
They disconnect and receive the update listening on their own port
(as selected by them). Nobody closes this port.

Then: Master plays first (s/he is Player 1), and sends out updates to
all players as vars change (eg, Location[1]).
Then Master sends PLAYER 0 2 to all players.
Master now listens to player 2.
Player 2 moves, sends updates to master.
Master passes this on to all others.
When P2 sends PLAYER 0 3, Master sends this then starts listening to P3.
etc. etc.
When P7 sends PLAYER 0 1, Master sends this out then plays.

This networking stuff seems to be okay now (though not totally sure!)
- moved from src/monopoly/c2/ to src/monopoly/ - original to old/