[Mozilla文档](https://developer.mozilla.org/zh-CN/docs/Web/API/WebSocket)
[官方文档](https://www.workerman.net)
#### 服务器
thinkphp5.0.23环境下安装
> 进入项目总目录
~~~
composer update
composer require topthink/think-worker ^1.0
~~~
> Fatal error: Call to undefined function Workerman\pcntl_signal()
> 需要安装php pcntl模块 上方php7扩展
~~~
php server.php start
~~~
## js端
~~~
ws = new WebSocket("wss://www.amlee.top:2347");
ws.onopen = function() {
alert("连接成功");
ws.send('tom');
alert("给服务端发送一个字符串:tom");
};
---------------------
作者:指尖-啪
来源:CSDN
原文:https://blog.csdn.net/yuexiage1/article/details/78912044
版权声明:本文为博主原创文章,转载请附上博文链接!
~~~
### 注意事项
>
# 下方的说明可能没用
~~~
yum -y install telnet
yum -y install xinetd
修改Xinetd配置文件
vim /etc/xinetd.d/telnet
~~~
~~~
# default: yes
# description: The telnet server servestelnet sessions; it uses \
# unencrypted username/password pairs for authentication.
service telnet
{
flags = REUSE
socket_type = stream
wait = no
user = root
server =/usr/sbin/in.telnetd
log_on_failure += USERID
disable = no
}
~~~
~~~
cat/etc/xinetd.d/telnet
systemctl restart xinetd.service
~~~