dongliao9018 2011-11-11 07:29
浏览 83
已采纳

PHP - 非阻塞,传出TCP连接 - 如何?

I'm somewhat familiar with the various methods of performing non-blocking IO within PHP, but the answer to this question seems to be eluding me. Let me describe what I am attempting to do:

I would like to have a static class called "Monitor" that I can throw various messages at. The class should then connect to an external TCP server and send those messages along - But I do not want to wait for that to happen. Everything, from the initial connection to the external server through the sending of the message should happen asynchronously, while my script has already moved along to other things.

Is this possible? I am currently attempting to use fsockopen(), stream_set_blocking(), etc...

  • 写回答

1条回答 默认 最新

  • duanleixun2439 2011-11-11 08:07
    关注

    What you are talking about is basically multi threading (which is not the usual way to use php). You can check this article to see how to do it. I wouldn't recommend to use this in production though.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题