PDA

Click to See Complete Forum and Search --> : Sockets Help


fartman_900
Oct 14th, 2006, 08:44 AM
I have a few questions about socket programming with my program. I found this site http://www.cs.rpi.edu/courses/sysprog/sockets/sock.html for programming sockets I C and unix (which is what I am using). The program is called Memory, where you have N cards arranged on the board and you have to match them up. Any number of players can connect to the server.

I really dont understand how to approach this with a client server design. My prof said to handle the requests sequentially but I have no idea how to do this, and we're not supposed to use threads.

Here is the basic program for the server:
There is an array of player structs
create the board and initialize stuff
create and bind socket for server
wait for connection from client
receive/send info from players

I'm making it so that when the player wants to send something, the first "parameter" of the message says what the player is doing and after that is all the neccessary info, and same with the server.

What I'm having trouble understanding is the whole idea with multiple sockets and the different players. So does each player need to have their own socket to send/receive or do they use the same socket? Any clarification about sockets is appreciated.

[EDIT]
Just to clarify, I dont understand how the server is to determine which player sent the info for the game.

DigiRev
Oct 15th, 2006, 03:23 PM
You are doing this in C++?