PHP 上的多个 TCP 套接字请求 [英] Multiple TCP Socket Requests on PHP

查看:44
本文介绍了PHP 上的多个 TCP 套接字请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用在 PHP 上制作的套接字服务器是否可以接受多个请求(并行)?如果可能,怎么做?

Is it possible to accept multiple requests (parallel) by using a socket server made on PHP? If possible, how ?

推荐答案

普通的 PHP 脚本无法接收多个请求.但是如果你真的打算创建一个套接字服务器(从 cmdline php 脚本开始),那么是的,这是可能的.

A normal PHP script cannot receive multiple requests. But if you really plan on creating a socket server (started as cmdline php script), then yes it's possible.

查看 http://pear.php.net/package/Net_Server - 它提供已经为此做了一些准备.具体来说,它使用 pcntl 函数分叉到多个进程以处理单独的 TCP 请求.

Look into http://pear.php.net/package/Net_Server - it provides already some preparations for that. Specifically it uses the pcntl functions to fork into multiple processes to work on separate TCP requests.

另一种选择是 http://nanoserv.si.kz/,它具有更多功能.

Another option would be http://nanoserv.si.kz/ which has a few more features.

这篇关于PHP 上的多个 TCP 套接字请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆