Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How does php connect to the server?

Shulou Source: shulou.com Published: 2022-05-31 10:56:49 09月11日 Update

This article mainly explains "how to connect php to the server". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to connect to the server with php.

1. Start the service

Php server.php

After startup, the cursor stops here and waits for other users to connect.

2. View the connection

Use the command netstat-an | grep port to see if the port is in Listening state

Netstat-an | grep 9501

(PS: note the IP address used by the server. If it is a 127.0.0.1 loopback address, the client can only use 127.0.0.1 to connect.)

3. Test the TCP server

A new window connects to the server using telnet

Telnet 127.0.0.1 9501

At this point, if you look at the machine that starts the service, you will find that there is data returned.

Php server.php > Client:Connect.

When returning to the client, enter hellp world and find that the write and read are successful

Root@iZ28evegw6zZ:~# telnet 127.0.0.1 9501 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is'^]'. Hellp world / / here is the entered command Server:hellp world / / recv () read command successfully Connection closed by foreign host. / / exit successfully and return to the server to observe root@iZ28evegw6zZ:/var/www/html# php server.php Client: Connect. / / connection success message Receive message: hellp world / / received data Client:Close. / / client exited successfully. Thank you for reading. The above is the content of "how php connects to the server". After the study of this article, I believe you have a deeper understanding of how php connects to the server, and the specific usage needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Service server success command client client learning content address data port observation input cursor loopback that is ideas situations articles more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno OPPO Reno Redmi macOS NVidia Apple