Click to See Complete Forum and Search --> : winsock protocols UDP and TCP
BlackCatSLO
Jan 12th, 2007, 10:12 AM
Im programming a massive online game 200+ connections and im in dilema, which protocol i have to use to have better performance, i know the UDP is faster but is meny times corrupted TCP is slow...
Soo which protocol UDP or TCP or both?
Al42
Jan 12th, 2007, 12:09 PM
UDP for data that can be corrupted without doing any damage, or if you want to use your own verification algorithm (send a block of data, wait for confirmation that it arrived okay). TCP for data thatyou want handled by the protocol and don't want to get corrupted. You don't select protocol based on speed.
jeroen79
Jan 12th, 2007, 12:25 PM
Performance vs reliability is one aspect.
UDP is fast, TCP is reliable.
You can make UDP reliable but that would require extra code on top of it, making it slower.
Data that changes often and is only briefly important (like someone's position) can be allowed to be lost.
Data that changes less often and is transmitted only once (like a player joining the game) should not be corrupted.
You'll have to weigh each thing that is transmitted to determine if speed or reliability is most important.
Then you can make the game either use UDP and TCP alongside eachother or create a 'hybrid' protocol using UDP that only does errorchecking for some things.
However:
A big advantage of TCP is that it allows two way traffic until either side closes the connection.
UDP is stricly a one time, one way only thing.
If a client is behind a NAT router then he can initiate a connection and send a message to the server but the server cannot initiate a connection or send a message to the client unless the router has the proper ports forwarded.
The server not being able to initiate a connection is not a problem, the server not being able to send a message is.
Therefore I would go for TCP.
BlackCatSLO
Jan 12th, 2007, 03:53 PM
tnx i will use TCP
raylynn
Jan 27th, 2007, 02:55 AM
do u has MSN?
My MSN:raylynn2008@hotmail.com
i developing p2p program,can discuss with you.
thanks!
the182guy
Jan 27th, 2007, 08:55 AM
If a client is behind a NAT router then he can initiate a connection and send a message to the server but the server cannot initiate a connection or send a message to the client unless the router has the proper ports forwarded.
The server not being able to initiate a connection is not a problem, the server not being able to send a message is.
Therefore I would go for TCP.
The server should never need to initiate a connection with the client. The client should always be the one initiating connections (outgoing), then port forwarding is never an issue.
For this type of app you should use a TCP connection for impoirtant data, and also use a UDP connection for less important data such as running,shooting,jumping etc.
That is the way big online games work.
BlackCatSLO
Feb 1st, 2007, 03:47 PM
I can not test UDP with winsock at home.
So i dont know what happen when is that udp packet bad...is packet in winsock automaticlly deleted by winsocket or is dataarrival triggered and string added to buffer...
sory this time for my bad english :confused:
the182guy
Feb 2nd, 2007, 08:09 AM
DataArrival is triggered when data is received, be it UDP or TCP protocol.
Why can't you test it at home? If you can test a TCP socket you should be able to test a UDP socket.
BlackCatSLO
Feb 2nd, 2007, 08:40 AM
Im running server and client on the same machine therfor on localhost as i know the packets can not be lost on localhost....
Yes i have few other machines but they are not cappable running XPs,NT or Win2k only two are cappable running XPs this im using now and another which is running server win2003 and is it not good to joke with him(don't touch working system :D)
Al42
Feb 2nd, 2007, 12:46 PM
If the packet is bad? In what way? Usually "bad" with UDP means that the packet never arrived. If there's bit corruption you'll have to check it yourself - maybe by sending a CRC with the chunk of data, then checking it on arrival. But you normally don't use UDP if you care whether the packet arrives - then you use TCP.
If you use UDP for something, just handle the data as it is if it arrives.
BlackCatSLO
Feb 7th, 2007, 05:33 PM
I have saw the directx 8 have directplaypeer,server,client
Where can i find SDK for this?
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.