In the previous article, I talked about some basic knowledge about computer networks and introduced socket. From this section, I started to get started.
1 Probability
TCP:Transimission Control Protocol Transmission Control Protocol.
UPD: User datav protocol user data packet protocol.
Both belong to the transport layer protocol, the fourth layer in the OSI model described in the previous article.
Comparison:
-
- TCP is connection-oriented, and UDP is non-connection-oriented)
-
- Slow TCP transmission speed and fast UDP transmission speed)
-
- TCP has a packet loss retransmission mechanism, but UDP does not; (Retransmission)
- TCP ensures data correctness and UDP may cause packet loss (correctness)
-
- TCP is suitable for transmitting a large amount of data, and UPD is suitable for transmitting a small amount of data. (Data volume)
2. TCP link Process
3. UDP Link
* Both images are from the network.
Socket programming
Socket is an API for TCP/IP networks. programmers use socket interfaces to exchange data.