c++ - What should i know about UDP programming? -


I do not mean how to connect to a socket What should I know about UDP programming?

  • Do I need to worry about bad data in my socket?
  • I think if I send 200bytes, then I will get 120 and 60 bytes separately?
  • Should I be worried about another connection to send bad data to the same port?
  • If data does not reach normally, then I can not see data for (usually) how long (250ms? 1 second? 1.75sec?)

I know?

"I think if I send 200bytes, then I can get 120 and 60bytes separately ?

When you are sending UDP datagrams, your reading size will be equal to your writing size. This is because UDP is a Datagram protocol, versus TCP's stream protocol, however, you can only write data up to the size of the MTU before the packet breaks or Could be left by the router. For general internet usage, there are 576 bytes, including secure MTU headers.

"Should I worry about another connection, so that bad data will be sent to me at the same port?"

You do not have a connection, you have a port, you will receive any data sent to that port, even if it is from where. You have to determine whether it is from the correct address.

If the data can not come normally, how long can I not see data for (usually) (250ms? 1 second? 1.75sec?)

The data can be lost forever, the data can be delayed, and the data can get out of order. If one of those things bothers you, then use TCP. Writing a reliable protocol at the top of UDP is a very trivial task and there is no reason to do this for almost all applications.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -