Home  >  Article  >  Backend Development  >  swoole - How to share variables during php multi-process programming?

swoole - How to share variables during php multi-process programming?

WBOY
WBOYOriginal
2016-08-04 09:22:131489browse

我写了个socket server,需要能共享父进程的$gsocks给子进程,但好像不能做到,我应该怎么做才能共享变量?

补充,额,memcache或者redis存的是字符串之类的把,我如何共享我问题代码中的socket res句柄?

代码如下:

服务端的:

客户端的:

回复内容:

我写了个socket server,需要能共享父进程的$gsocks给子进程,但好像不能做到,我应该怎么做才能共享变量?

补充,额,memcache或者redis存的是字符串之类的把,我如何共享我问题代码中的socket res句柄?

代码如下:

服务端的:

客户端的:

memcacheredis之流即可搞定。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn