OK, this is important for me. I do understand how a basic server-client connection work and have implemented a quick chat room program in WinSock. My next goal is to create a multiple connection (possibly a UDP/IP connection, I'm still learning) server. And my question is not what is the best way to make such connections and transmit data but what would be certainly a good (and fast) way of doing so. So I'm turning to you guys, I know some of you are more experienced and can help. So here is a detailed explanation of what I would like to do:

I want to have a machine that picks to be a server. The user of that machine then gives out his/her server ip to 3 or more (possibly up to 16, but is meaningless at this point, it just has to be more than 1, then I will be able to pull it off with as many as I need) clients. These clients connect to the server. Up to this point I'm pretty much an expert (with both TCP and UDP techniques). So the following are the questions that need to be answered:

1. Is it reasonable/possible to have a blocking connection-oriented TCP/IP based network to have more than 1 clients exchange information with each other and the server?

2. Or is it best to go with UDP/IP to pull such thing off?

3. If it's best to use UDP for this over TCP; why?

And the most important one:

4. What exactly can and should be done to make a network with 2 or more clients and (1 server obviously) with which it could be possible to distribute information at Reasonably same time to all clients (and the server itself). To make it clear, what I'm planning to do is to make a program (yes it's a game) that lets users to connect to a server and play a game on it. I would think that all clients and the server need to interpret all information at the same time. How can this information be then displayed on the screen of all the cliens and the server? I need an explanation of how this can work and what protocol is best used for this kind of thing. (remember that I'm only studying WinSock for 24 hours, so I don't understand some certain things).

I just want to add that the server should be a player too, it's not just for storing game information.

Any help would be appreciated a lot,
Greg
Posted on 2003-02-18 15:48:45 by gregd

1. Is it reasonable/possible to have a blocking connection-oriented TCP/IP based network to have more than 1 clients exchange information with each other and the server?

Yes it's possible, but if you're going to use blocking sockets you may need multiple threads if the number of clients is greater than 64 (the maximum number of sockets select can handle at the same time). You could use a thread per client to keep things simple, which is perfectly reasonable with a low number of clients. Threads are relatively costly system resources but that doesn't really matter as long as you don't deal with thousands of connections.

2. Or is it best to go with UDP/IP to pull such thing off?
3. If it's best to use UDP for this over TCP; why?


Use TCP instead of UDP unless you've got a *very good* reason not to. TCP is connection oriented, and most importantly, reliable. UDP is connectionless and *not* reliable. Considering your goals I would go for TCP. UDP might be a bit faster (which can be important in games where clients should be able to react fast, like unreal or something), but it adds a lot overhead.

4. What exactly can and should be done to make a network with 2 or more clients and (1 server obviously) with which it could be possible to distribute information at Reasonably same time to all clients (and the server itself). To make it clear, what I'm planning to do is to make a program (yes it's a game) that lets users to connect to a server and play a game on it. I would think that all clients and the server need to interpret all information at the same time. How can this information be then displayed on the screen of all the cliens and the server? I need an explanation of how this can work and what protocol is best used for this kind of thing. (remember that I'm only studying WinSock for 24 hours, so I don't understand some certain things).

You probably need to write your own protocol for your game. Just think of the actions possible, the information that needs to be transfered (player movements, player actions etc.) and try to put it in a nice format.

I just want to add that the server should be a player too, it's not just for storing game information.

This problem is best solved by letting the user at the server connect via a client program just like any other player, it saves you from the trouble of dealing seperately with the server player and client players.

Thomas
Posted on 2003-02-19 10:32:34 by Thomas