Home  >  Article  >  Backend Development  >  TCP connection establishment and closing status and data transmission communication process [including PHP socket API test experiment code]

TCP connection establishment and closing status and data transmission communication process [including PHP socket API test experiment code]

藏色散人
藏色散人forward
2019-09-26 09:09:592597browse

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

socket API

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 connection establishment and closing status and data transmission communication process [including PHP socket API test experiment code]

##TCP/IP options file

TCP connection establishment and closing status and data transmission communication process [including PHP socket API test experiment code]

Then we start the service

Service status viewing command:

netstat -ntlapc The status can be refreshed every second

tcpdump tool:

tcpdump -A -XX -i lo

On the client side, we can use the telent tool to connect and test

The test diagram is as follows

TCP connection establishment and closing status and data transmission communication process [including PHP socket API test experiment code]

TCP connection establishment and closing status and data transmission communication process [including PHP socket API test experiment code]

TCP connection establishment and closing status and data transmission communication process [including PHP socket API test experiment code]

TCP connection establishment and closing status and data transmission communication process [including PHP socket API test experiment code]

##Connection and shutdown diagram

TCP connection establishment and closing status and data transmission communication process [including PHP socket API test experiment code]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

TCP connection establishment and closing status and data transmission communication process [including PHP socket API test experiment code]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!

Statement:
This article is reproduced at:learnku.com. If there is any infringement, please contact admin@php.cn delete