Advertisement

Simple Game, Complex Networking

Started by June 09, 2005 07:00 PM
12 comments, last by OrangyTang 19 years, 8 months ago
I have been trying to get a small simple networking game running for the past 2 days now and I am stuck. I have been using Winsock, but I think its a bit over my head. My question to you guys is, is there anyway to get something networked without going through all the winsock creation and socket binding. All I need to do for this game is to send x and y values back and forth to the server and then to the other client and vice versa.
My Current Project Angels 22 (4E5)
The Forum FAQ is a good place to start; it lists a number of libraries.

However, distributed programming is, in general, hard, and you can't expect to get it all right in just two days of work. Two days isn't much compared to the ten years it takes to become an expert in a field...
enum Bool { True, False, FileNotFound };
Advertisement
I dont plan on being an expert on the subject, but being the only programmer in my indie team puts some pressure on me to know a bit of everything. Anyways, thanks for the help, I'll try some of those libs. The main problem I had with Winsock was that I could get the server to work because it is usually written as a simple console app in tutorials, however the client is the hard part because all the tutorials I have found on Winsock Game Programming have had the client be some fancy DirectX app with lots of stuff in the code not pertaining to networking at all. Anyways, if anyone knows of a place with a sample server and client that just connect to eachother and do nothing else, please let me know.
My Current Project Angels 22 (4E5)
If you are doing it with UDP then the server and client is almost identical, just one sends the first message, and the other waits
Medium-simple sockets code (portable between UNIX and WinSock) using UDP can be found here.
enum Bool { True, False, FileNotFound };
try gnet.org.
Advertisement
Quote from www.gnet.org:

Quote:
GNET is an award-winning environmental technology, news and business center that promotes the use of innovative environmental technologies. This site is made possible by a cooperative agreement from the National Energy Technology Laboratory and the Department of Energy's Office of Science and Technology.


I don't think that's what you actually meant :-)
enum Bool { True, False, FileNotFound };
Thanks for all the replies guys, but I just got Winsock to work and I think I will stick to that. I do have a nother question however. When I send my packet containing playerdata, should I create a struct that hold all the data and then just send one packet that contains the struct, or should I send all the variable seperately in 4 or 5 packets?

I have 8 possible players in a game at one time, so if I send them all the other players information(x position, y position , angle , weapon , name , etc) seperately it comes out to something like 400 packets every tick.
My Current Project Angels 22 (4E5)
You should mash all updates you want to send to a single player at one point in time into a single packet. That way you save on packet overhead. It may serve you well to think of "messages" between game entities, and "packets" (in actual UDP) as a conglomeration of "messages".
enum Bool { True, False, FileNotFound };
Quote:
Original post by hplus0603
You should mash all updates you want to send to a single player at one point in time into a single packet. That way you save on packet overhead.

And make your system more fragile to dropped packets. At some point this starts to become more significant than the packet overhead, so you obviously want to keep your packets between some reasonable min and max sizes.

This topic is closed to new replies.

Advertisement