简体   繁体   English

如何打开PHP套接字连接并从客户端请求/维护数据

[英]How to open php socket connection and request/maintain data from client

So I want to make a daemon.php file which can open a port on a give ip address and request data from client.php and with the browser to listen/read to earlier pipe (Would that be a problem for the security or not?). 所以我想制作一个daemon.php文件,该文件可以在给定ip地址上打开端口,并从client.php请求数据并使用浏览器来侦听/读取到较早的管道(这是否会对安全性造成影响? )。 I fount this funphp tutorial which seems to be good but is more like a cronjob, I found also function stream-socket-server but can handle only one request and then shuts down, and I really don't know where exactly to put listener. 我找到了这个funphp教程 ,看起来不错,但更像是cronjob,我发现它也可以运行stream-socket-server,但是只能处理一个请求,然后关闭,我真的不知道将监听器放在哪里。

You can use the PHP Built-In Server 您可以使用PHP内置服务器

  • Add PHP to your PATH environment variable PHP添加到您的PATH环境变量
  • Start your server on a given port, ex: php -S localhost:8000 OR 在给定端口上启动服务器,例如: php -S localhost:8000 OR
  • Start with a router script, ex: php -S localhost:8000 rt.php 路由器脚本开始,例如: php -S localhost:8000 rt.php
  • Now, just open your browser and type; 现在,只需打开浏览器并输入; localhost:8000

    声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

     
    粤ICP备18138465号  © 2020-2024 STACKOOM.COM