Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does php connect to the server?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report