Skip to content

Instantly share code, notes, and snippets.

@taotao
Created December 30, 2016 01:55
Show Gist options
  • Save taotao/b88b03fcbaef2d70368947754bb9d928 to your computer and use it in GitHub Desktop.
Save taotao/b88b03fcbaef2d70368947754bb9d928 to your computer and use it in GitHub Desktop.

Comparison

  • TCP:

    • Connection based
    • Guaranteed reliable and ordered
    • Automatically breaks up your data into packets for you
    • Makes sure it doesn’t send data too fast for the internet connection to handle (flow control)
    • Easy to use, you just read and write data like its a file
  • UDP:

    • No concept of connection, you have to code this yourself
    • No guarantee of reliability or ordering of packets, they may arrive out of order, be duplicated, or not arrive at all!
    • You have to manually break your data up into packets and send them
    • You have to make sure you don’t send data too fast for your internet connection to handle
    • If a packet is lost, you need to devise some way to detect this, and resend that data if necessary

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment