Python advanced programming lecture 6: socket programming-TCP

1. Introduction to TCP

TCP protocol, transmission control protocol, is a connection-oriented, reliable, byte stream-based transport layer communication protocol.
TCP communication requires three steps: connection creation, data transmission, and connection termination.
In the TCP communication model, before communication starts, a related connection must be established before data can occur.

2. TCP features

  • 1. Connection-oriented

The communication parties must establish a connection before data transmission

  • 2. Reliable transmission
  • TCP uses a sending response mechanism
  • Timeout retransmission
  • Error checking
  • Flow control and congestion management

The difference between TCP and UDP:
1. TCP is connection-oriented; UDP is connectionless, that is, there is no need to establish a connection before sending data.
2. TCP provides reliable services. That is to say, the data transmitted through the TCP connection has no errors, no loss, no duplication, and arrives in order; UDP does its best to deliver, that is, it does not guarantee reliable delivery.
3. UDP has better real-time performance and is more efficient than TCP High, suitable for high-speed transmission and real-time communication or broadcast communication.
4. Each TCP connection can only be point-to-point; UDP supports one-to-one, one-to-many, many-to-one and many-to-many interactive communications.
5. TCP requires more system resources, while UDP requires more system resources. less.

Guess you like

Origin blog.csdn.net/scyllake/article/details/97291604