What is the difference between TPC and UDP?
TCP and UDP are the major transport protocols. If you remember from computer network course, there are 5 layers each packet passes in the network - application, transport, network, link and physical, so UDP and TCP corresponds to Transport layer of Network. Transport layer can create up to 65535 port, to enable multiple applications use same network layer without any problem. For example: Browser you are viewing this website uses TCP port 80 to retrieve data from web server.
Why do we have many protocols? Because we need different kind of features for each application structure. For example multiplayer games such as racing game - doesn't need to check if packet from server reaches clients. Instead racing game server needs to have fast network. In this case we need UDP packet size is smaller than TCP and it doesn't need stable connection. Also UDP connections doesn't control to order of packets. Another example for good use of UDP is live communation software like Skype.
Let's assume another scenario where we are developing chess game, we don't need fast network but we need reliable transport layer to check if all clients receive same moves. We need TCP connection for this type of application. Also TCP connection must be established first via handshaking, then start sending data. Another example for TCP connection is banking application - where security and network reliability is crucial.