Archived

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

ceilingfish

Internetworking?

Recommended Posts

Hi, I am about to start on my 3rd year at university, which will involve a large project, in my case a multiplayer chess game. I need to figure out some way of communicating over the internet in relatively short timespans. The final product is supposed to be designed in a distributed style, so there should be no big differences in how you play the game against an opponent on the internet to an opponent that is sitting next to you. Ideally I would like to develop a system for communicating between the game distributable and the server that could be stored in main memory and then transmitted to the opponent, rather than having to write a file to some point on the server. Has anyone got any ideas how I can get this kind of communication? Tom Customer: Help my trousers don''t go with my coat! Support: Where did you get the trousers? Customer: Isaac Burton Menswear! Support: Ahh, I see the problem, those are IBM trousers, they aren''t mack compatible

Share this post


Link to post
Share on other sites
Why are you doing a client/server thing? Something like a chess game is never more than 2 people... This, to me, screams peer-2-peer. And considering the terseness of an abreviated chess move, your packet size should be miniscule and only need to be sent when a move is made. So minimal packets to pump. It sounds like you are trying to make it more difficult than it needs to be.

My sig used to be, "God was my co-pilot but we crashed in the mountains and I had to eat him..."
But folks whinned and I had to change it.

Share this post


Link to post
Share on other sites
No that''s my university making things more complicated than necessary. I HAVE to include a server implementation, which is able to concurrently deal with several games at once, and collect statistics of all the currently available games. Which is real friendly as implementation is going to be in C++, which as far as my research has indicated doesn''t have any built in APIs for concurrent programming support (I''m really hoping I''m wrong though).

I am hoping to be able to add a peer-to-peer mode as well, but I''ve only got a year...

However even if I was able to do this peer-to-peer, do you know any way I can communicate data between clients without having to write data to a file?

Share this post


Link to post
Share on other sites
quote:
However even if I was able to do this peer-to-peer, do you know any way I can communicate data between clients without having to write data to a file?
You can use Winsock for networking, if that''s what you mean. Just #include winsock2.h in your project and add ws2_32.lib to the linker dependencies.


"For crying out loud, she has fishes coming out of her head on either side. How can you find this hot?!"

"If anyone sees a suspicious, camouflaged factory being carried across the desert, they should report it immediately."

Share this post


Link to post
Share on other sites
Valderman! you furry beauty! And there I was thinking that I was going to have to get very deep down digging around trying to stuff things in TCP IP packets. You purple wonder! this is exactly the sort of thing that I was looking for. I was beginning to wonder how the hell comms between any application wanting to get access to the internet actually happened, eg how Kazaa actually transferred data from one persons computer to another.

Valderman, if you weren't on the internet I would kiss you!

Customer: Help my trousers don't go with my coat!
Support: Where did you get the trousers?
Customer: Isaac Burton Menswear!
Support: Ahh, I see the problem, those are IBM trousers, they aren't mack compatible

PS I assume that WinSock is capable of communicating over the internet as well as networks?

Yes of course it is, sorry I am being blonde and lazy

[edited by - ceilingfish on July 27, 2003 9:21:43 AM]

Share this post


Link to post
Share on other sites
Heh - you seem to have already caught it but I will state it for the record. The Internet is nothing but an expanded network. If you are talking TCP/IP, you are talking internet.

My sig used to be, "God was my co-pilot but we crashed in the mountains and I had to eat him..."
But folks whinned and I had to change it.

Share this post


Link to post
Share on other sites
Using TCP is fairly straight forward once you have gotten past the abortive setting up of a socket (you would not believe how many tutorials on this (as well as most docs) are so very wrong)

The most challenging thing you''ve mentioned is the necessity for one server to field many games. The simplest hack (as used by Apache and most UNIX daemons) is to fork a child to handle the session with a dup()''d socket handle. In Windows you could spawn a new thread to do the same thing (avoiding the dup()''ing in the process)

The advantage of using threads becomes apparant when you realise that BSD compliant socket calls are *blocking* and will hold your program to ransom if you don''t use ''em right.

Share this post


Link to post
Share on other sites
I was thinking perhaps of using only a limited number of threads, say 50 or something and then queueing excess orders, until one of these threads is available to deal with it. I thought it might be a vulnerability if a hacker just started up loads and loads of games then he may be able to start enough threads to crash the server by overuse of the CPU.

But if Apache et al use a thread spawning mechanism then I assume that there must be some method of preventing an overload on the CPU....

Share this post


Link to post
Share on other sites