[] TCP network programming network programming foundation

Creative Commons License Copyright: Attribution, allow others to create paper-based, and must distribute paper (based on the original license agreement with the same license Creative Commons )

Outline

English: Transmission Control Protocol, abbreviated as TCP

TCP is a transport control protocol ; is a connection-oriented , reliable , based on the byte stream transport layer communication protocol defined by the IETF RFC793

Establish and Release connection: three-way handshake, waving four

TCP has a checking mechanism, reliable, stable data transmission

TCP connection, transmission flow


TCP can do
chat messaging, push
single voice, video chat
almost UDP can do can do, but need to consider the complexity, performance issues
Restriction: can not be broadcast, multicast, and other operations

TCP kernel API

socket (): create a Socket

Socket just created can be stateless in subsequent binding operation information in response

bind (): bind a Socket to a local address and port

connect (): connection to a remote socket

accept): to accept a new connection

This is unique to the server

write (): write data into the output stream Socket

read (): read data from the input stream Socket

Process
Client:
Here Insert Picture Description
: server-side
Here Insert Picture Description
relationship with the process of Socket
Here Insert Picture Description

TCP connection reliability

Three-way handshake:
Here Insert Picture Description
three-way handshake is necessary random
Here Insert Picture Description
four wave:
Here Insert Picture Description
ACK are loopback command
U is a random value V is a random value

TCP transmission reliability

Here Insert Picture Description
Sliding window protocol

Reference details Computer Network] Xie Xiren note transport layer

Guess you like

Origin blog.csdn.net/qq_42322103/article/details/94965441