Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


#Actualsamoth

Posted 19 October 2013 - 10:22 AM

This is not so much a question about whether one or the other is more efficient, but about how things work.

 

If you are using UDP, then you will only have one socket (unless you plan to have every client use a different port, which would be kind of a weird design).

 

If you are using TCP, then you will have one listening socket, plus one socket per client that connects. It simply isn't possible to do something different.

 

Whether you use one or the other depends mainly on whether or not you can answer one question with "yes": "Do you need your data with as little delay as possible, and is it possible to ignore missing packets?" If the answer is "yes", you want UDP. If you are not sure or the answer is "no", stop thinking about UDP, you want TCP.

 

TCP works perfectly well and is not any "slower" than UDP. They perform exactly identical 99% of the time, but TCP is easier to use, as it emulates stream of data and is reliable, much as if you read from a file. The only time at which they differ (in their performance characteristics) is when packets are lost. TCP will wait for a short while and resend packets when no ACK comes in, and the other end will wait until the data has arrived in the correct order. Insofar, TCP works contrary to how IP (the protocol both TCP and UDP build on) works -- UDP on the other hand works exactly like IP. UDP will try to deliver each packet you send, but if it doesn't arrive, that's just bad luck for you. If you can live with this, it's perfect. If you can't live with that, you want TCP (it's possible to implement reliability on top of UDP too, but that's not trivial to do, and easy to get wrong, and it will not perform any better (though possibly worse) than TCP).


#3samoth

Posted 19 October 2013 - 10:20 AM

This is not so much a question about whether one or the other is more efficient, but about how things work.

 

If you are using UDP, then you will only have one socket (unless you plan to have every client use a different port, which would be kind of a weird design).

 

If you are using TCP, then you will have one listening socket, plus one socket per client that connects. It simply isn't possible to do something different.

 

Whether you use one or the other depends mainly on whether or not you can answer one question with "yes": "Do you need your data with as little delay as possible, and is it possible to ignore missing packets?" If the answer is "yes", you want UDP. If you are not sure or the answer is "no", stop thinking about UDP, you want TCP.

 

TCP works perfectly well and is not any "slower" than UDP. They perform exactly identical 99% of the time, but TCP is easier to use, as it emulates stream of data and is reliable, much as if you read from a file. The only time at which they differ (in their performance characteristics) is when packets are lost. TCP will wait for a short while and resend packets when no ACK comes in, and the other end will wait until the data has arrived in the correct order. Insofar, TCP works contrary to how IP (the protocol both TCP and UDP build on) works -- UDP on the other hand works exactly like IP. UDP will try to deliver each packet you send, but if it doesn't arrive, that's just bad luck for you. If you can live with this, it's perfect.


#2samoth

Posted 19 October 2013 - 10:17 AM

This is not so much a question about whether one or the other is more efficient, but about how things work.

 

If you are using UDP, then you will only have one socket (unless you plan to have every client use a different port, which would be kind of a weird design).

 

If you are using TCP, then you will have one listening socket, plus one socket per client that connects. It simply isn't possible to do something different.

 

Whether you use one or the other depends mainly on whether or not you can answer one question with "yes": "Do you need your data with as little delay as possible, and is it possible to ignore missing packets?" If the answer is "yes", you want UDP. If you are not sure or the answer is "no", stop thinking about UDP, you want TCP.

 

TCP works perfectly well and is not any "slower" than UDP. They perform exactly identical 99% of the time, but TCP is easier to use. The only time at which they differ is when packets are lost. TCP will wait for a short while and resend packets when no ACK comes in, and the other end will wait until the data has arrived in the correct order. Insofar, TCP works contrary to how IP (the protocol both TCP and UDP build on) works -- UDP on the other hand works exactly like IP. UDP will try to deliver each packet you send, but if it doesn't arrive, that's just bad luck for you. If you can live with this, it's perfect.


#1samoth

Posted 19 October 2013 - 10:13 AM

This is not so much a question about whether one or the other is more efficient, but about how things work.

 

If you are using UDP, then you will only have one socket (unless you plan to have every client use a different port, which would be kind of a weird design).

 

If you are using TCP, then you will have one listening socket, plus one socket per client that connects. It simply isn't possible to do something different.

 

Whether you use one or the other depends mainly on whether or not you can answer one question with "yes": Do you need your data with as little delay as possible, and is it possible to ignore missing packets? If the answer is "yes", you want UDP. If you are not sure or the answer is "no", stop thinking about UDP, you want TCP.


PARTNERS