Home > Article > Backend Development > TCP connection establishment and closing status and data transmission communication process [including PHP socket API test experiment code]
This article uses PHP code to test a communication process of the TCP transport layer.
TCP/IP Protocol
You can check the details of this protocol by yourself< ;
PHP’s tcp/udp API content is the content in the PHP manual
Tested PHP version
TCP connection establishment and closing status and data transmission communication process
PHP code[This is an example in the manual]
socket service type
##TCP/IP options file
Then we start the serviceService status viewing command:
netstat -ntlapc
tcpdump tool:The status can be refreshed every second
tcpdump -A -XX -i loOn the client side, we can use the telent tool to connect and testThe test diagram is as follows
##Connection and shutdown diagram
If initiated by the client When closed, the status is:
The client first sends an end message FIN packet, which is in the FIN_WAIT1 state. The server confirms that the response is in the CLOSE_WAIT state.
The client is in the FIN_WAIT2 state at this time. When the server also sends a FIN end message, the server is in the LAST_LOCK state. After the client confirms, it is in the TIME_WAIT state. The server is closed CLOSED
State transition diagram
The test is the same whether you use the SOCKET API provided by PHP, SWOOLE or C!
The above is the detailed content of TCP connection establishment and closing status and data transmission communication process [including PHP socket API test experiment code]. For more information, please follow other related articles on the PHP Chinese website!