基于GatewayWorker实现简单聊天室功能

版权声明:作者:Yfw 出处:https://blog.csdn.net/u012577474 本文版权归作者和CSDN共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接。 https://blog.csdn.net/u012577474/article/details/89455127

前言
GatewayWorker基于Workerman开发的一个项目框架,用于快速开发TCP长连接应用,例如app推送服务端、即时IM服务端、游戏服务端、物联网、智能家居等等…

一、准备工作

Linux下GatewayWorker 源码下载地址:
http://www.workerman.net/download/GatewayWorker.zip
GatewayWorker 手册地址:
http://doc2.workerman.net/

安装PHP posix扩展:

1.安装php-posix
#yum -y install php-process
2.验证是否安装上了
#php -m|grep posix
posix                           #可以看到php已经支持posix了

linux安装telnet服务:
yum install telnet-server -y
yum install xinetd -y
yum install telnet

**

二、GatewayWorker 安装与启动

**

解压安装GatewayWorker:
unzip GatewayWorker.zip
启动GatewayWorker:
cd GatewayWorker  #进入到GatewayWorker目录下
php start.php start  #启动GatewayWorker服务

从上图可以看到已经启动成功,Gateway监听在端口8282!
在这里插入图片描述

三、实现聊天(附图)

在命令行窗口执行telnet 127.0.0.1 8282后,输入任意字符即可聊天。
注意:不是本机则把127.0.0.1 换成实际IP地址,防火墙要开放8282端口。
在这里插入图片描述

扫码下方二维码关注公众号,每天分享编程开发及linux相关知识。

联系邮箱:[email protected]

在这里插入图片描述

Talk is cheap. Show me the code。————Linus Torvalds

—————————————————————————————————————————————

猜你喜欢

转载自blog.csdn.net/u012577474/article/details/89455127