Lots of people have heard about TCP.Actually, whoever is reading this article knows what TCP means since he have an Internet connection. but what they’d have guessed is that TCP is only the ‘TCP/IP’.
in a matter of fact, TCP/IP is called a protocol suite. so it has much much more organs than the TCP and IP.
this is an overview figure of TCP/IP protocols on Unix from the application layer to the Datalink layer (from the seventh layer to the 2nd layer -Check the OSI networking model) Click the image

whatever under the API underlines applications that uses normal Sockets.
you may ignore the figure :). it will look too complicated to lots of people, but it’s just to clear the point of view.
back to what we were talking about….Oh!!! UDP vs TCP. hm..Ok!!!
TCP : Stands for Transmission Control Protocol . it’s a reliable byte stream. TCP sockets are stream sockets. Plus TCP takes care of the small details like ACKs and timeout and retransmitting.
UDP : Stands for User Datagram Sockets. UDP sockets are datagram sockets. it’s not reliable so u can never know if your socket reached it’s destination.
BOTH TCP and UDP can use IPv4 and IPv6
is that it?!!! – No, Come on put your glasses on!!
let’s start with the simple one
UDP :-
it’s a simple transport-layer protocol. the UDP application writes datagrams to the UDP socket. and then the socket is sent to the destination but as I said before u can’t know if your data reached the destination or didn’t.
Hey!! Watch out i can read minds. I know what you are thinking in. and yes the lack or reliability is one big problem for the applications that use UDP. and handling such a lack needs lots of lines of codes to support ACKs and timeout…etc
UDP datagram is like a record and have a length. If a datagram reaches it’s final destination correctly, then the length is sent to the destination. But, what you should have noticed is that TCP is byte-stream, but UDP applications are bounded with the length of the record of a datagram.
But what makes a UDP great is that it’s a connectionless service. means that a you can send a datagram on a socket to Destination1 and immediately send another datagram on the same socket to Destination2. and you can also receive many datagrams on one UDP socket. OK!! enough UDP!!!
TCP :-
this protocol provides connection between the client and server. which means TCP establish connection between two points, Exchange data on a connection and terminate connection.
Unlike UDP, TCP is reliable protocol. when you send data to a destination the protocol require and Acknowledge(ACK) in return. If no ACK is received it retransmits the data after some time. the time it waits to get an ACK is called round trip time. but how can it know how much time needed to get back an ACK? – Actually, TCP contains algorithms that calculate the round trip time.
TCP also enhances it’s reliability by sequencing every byte it send , so if two segments are sent out of order the TCP on the destination will just reorder them based on their sequence. and on duplication issues if the destination receives two segments with the same sequence number it will just discard one of them.
the TCP protocol is also  full-duplex, this means it can receive and send data on a connection at any time.
there is much much more details. specially for TCP but we will leave this for a later post isA.