Advertisement

Some other silly questions about network programming

Started by May 05, 2005 08:19 AM
14 comments, last by devgamedev 19 years, 9 months ago
Hello! I'm just a very newbie in network programming. All I wanna do is a multiplayer race car. So I wanna ask you some little questions: 1) Should I use peer to peer or client/server protocol? 2) What data should I have transmit to one user to another? 3) UDP or TCP? rapidity or security? I look on your forum but I did not find answers to my questions. Thanks in advance.
I'm no expert in this but I'll try anyway...

Quote:

1) Should I use peer to peer or client/server protocol?


Client/Server. I think that's the simplest and the best.

Quote:

2) What data should I have transmit to one user to another?


Send the car's position and rotation to the server, which then sends it to the other players. Maybe you need some more data, I haven't thought about it too much ...

Quote:

3) UDP or TCP? rapidity or security?


UDP. You need the speed. If a packet get's lost TCP sends it again. In a racing game that packet would already be old
Advertisement
A client/server setup is much easier to implement, and will reduce intraplayer traffic. You could try peer-to-peer, but you may have problems with players playing across the internet. Depends on your implementation.

As for the data you send, it's whatever you'll be using. Position and direction are good, but you may also need things like velocity, momentum, etc, for any dead-reckoning you plan on using.

And if it's a real-time game, use UDP. Just make sure you game can handle packet loss.
-----BEGIN GEEK CODE BLOCK-----Version: 3.12GCS/M/S d->+(++) s+: a19? C++++ UL++ P+++ L+ !E W+++ N+ o++ K? w!O M-- V? !PS PE Y+ PGP t++ 5+++ X R tv+> b+(++)>+++ DI+++>+++++ D++G e>++++ h! r y?------END GEEK CODE BLOCK------
Quote:
Original post by overflowed_[/i

And if it's a real-time game, use UDP. Just make sure you game can handle packet loss.


Thanks for your answer.
And how can I make my game handle packet loss? (I am very very newby in network programming ... :( )

For now forget about packet loss. In 99.999% cases, packets will not be lost (especially on LANs), unless you are doing serious multi-continental networking. By the time you get your game running using very bsic networking, you will also have the knowledge to then implement network-safety issues, such as packetloss, crc, etc...

I guess my point is that I'd focus on the functional aspects of the game for now. sounds cool BTW...
Quote:
Original post by superdeveloper
I guess my point is that I'd focus on the functional aspects of the game for now. sounds cool BTW...


What is BTW?

So you want I just focus on connecting, sending data and receiving data, that is?

ANother question : is there a library that permits to me to program one game for Windows, XBOX, PS2? one code for all plate forms? Is it possible or is it utopia??
Advertisement
BTW -- by the way (I.e. your game sounds cool, by the way...)

Since you are learning networking, get it up and running by following the samples on how to initialize the sockets, then doing some sending & receiving. Ensure that you assert every function's return value to be the default "success code" (I.e. fix each error at each function as you work on the networking steps).

Later on when you get a feel for how it works, begin to put in various formal error checking at each function call to ensure that the application is graceful and robust.

After that, begin to put in additional safety measures (such as numbering your packets, CRC tests) so that your networking system as a whole is robust.
Thanks for all your answers!!!!
I'll try to do that...

Hi,

For cross-platform code that is readily accessible and easy to use, I would recommend RakNet. As a matter of fact, there are many 3rd party networking libraries available. Take your pick. I've just found RakNet extremely easy to use.

GCS584
But it seems to work only on PCs, no??

This topic is closed to new replies.

Advertisement