PDA

View Full Version : TCP or UDP



jamesa
22-02-2005, 11:48 AM
Hello,

I am developing a simple online card game. What do you think is the best method? using TCP or UDP?

I plan to add a chat room also in the game. The game will consist 4 players.

What is a good network component for this kind of games? I plan to use INDY. Any other better one?

Thank you

WILL
22-02-2005, 05:42 PM
Indy is a pretty good one. It even works for Lazarus I believe...?

If you wanted to try something else there is a SDL_net component that JEDI-SDL supports.

{MSX}
22-02-2005, 07:38 PM
Hello,

I am developing a simple online card game. What do you think is the best method? using TCP or UDP?


A card game doesn't suffer for a little latency, so i suggest you to use TCP, which is easier and reliable.



What is a good network component for this kind of games? I plan to use INDY. Any other better one?


Well, Indy or manual socket :P If you don't have particular needs i suggest you to use Indy.

jamesa
22-02-2005, 11:05 PM
Thanks for the information, yes I agree that for card game we can use TCP without any problem.

But one thing that concern me, for general online game, is problem with NAT router/firewall.

Player behind NAT router is not easy to "create game" (hosting online game). Traditionally, this needs to setup port forwarding in the NAT router, to redirect incomming packet to the local ip address of the hosted game.

I read several articles about a solution for this particular problem:

http://www.mindcontrol.org/~hplus/nat-punch.html
http://midcom-p2p.sourceforge.net

Basically it uses a third server, "INTRODUCER" to help.

I quite understood the concept, but I cant get my experiment work:

I tried to host a UDP server behind a NAT router.

(1) I put a UDP SERVER_1 on Port 5000 on local IP address 10.0.0.1

(2) A NAT_Router act as gateway, IP address 100.0.0.1 (public ip)

(3) UDP SERVER_2 on Port 5000, IP address 100.0.0.2 (public ip). This is the INTRODUCER service.

(4) UDP SERVER_3 on Port 5000, IP address 100.0.0.3 (public ip).

....

SERVER_1 sent data to SERVER_2.
SERVER_2 will get the IP address of the NAT_Router.

Using this information, why SERVER_3 can not send any data SERVER_1 ? Because I assumed, after SERVER_1 sent data to SERVER_2, the NAT_Router will create a translation table that will redirect incoming connection on port 5000 to SERVER_1

Anyone has implemented this using Delphi ?

Thanks.

User137
06-06-2005, 11:14 AM
Hello,

I am developing a simple online card game. What do you think is the best method? using TCP or UDP?


A card game doesn't suffer for a little latency, so i suggest you to use TCP, which is easier and reliable.

Easier you say? I would say they are even. They just work a bit differently. UDP doesn't need to keep connection so there's no client list. UDP sends faster but doesn't resend if packets get lost or come corrupted.

I'm using totally free component WSockets, which provides TCP and UDP client and server for both. Earlier used SimpleSockets2, but found this one better and more reliable.

sardaukar
26-08-2005, 04:05 PM
i think asphyres net component uses udp and internally resends packages plus it gives you the benefit of compression.

WILL
27-08-2005, 06:38 PM
User137, do you have a link to the WSockets component package that you use?

User137
01-09-2005, 01:15 AM
Here's WSockets 1.20 mirrors (can't rely on 1 can we :wink: ):
http://homepages.borland.com/torry/vcl/internet/sockets/wsock120.zip
http://www.smartdata.com.au/delphi_isp/wsock120.zip
http://delphi.icm.edu.pl/authors/a0001198.htm

L505
06-09-2005, 05:26 PM
There is also Synapse