linux 安装 websocketd

1.下载

wget https://github.com/joewalnes/websocketd/releases/download/v0.3.0/websocketd-0.3.0-linux_amd64.zip

注意是amd架构

 

2.解压

unzip websocketd-0.3.0-linux_amd64.zip

 

3.复制websocketd到/usr/bin

cp ./websocketd /usr/bin/websocketd

 

4.添加到path

echo "export PATH=$PATH:/usr/bin/websocketd" >> /etc/profile
source /etc/profile

 

5.启动服务

websocketd  --help  # 查看帮助
[root@localhost-db01 ~]# websocketd  --address=0.0.0.0 --port=8888 ls
Sun, 30 Jun 2019 15:33:03 +0800 | INFO   | server     |  | Serving using application   : /usr/bin/ls 
Sun, 30 Jun 2019 15:33:03 +0800 | INFO   | server     |  | Starting WebSocket server   : ws://0.0.0.0:8888/
Sun, 30 Jun 2019 15:34:23 +0800 | ACCESS | session    | url:'http://192.168.0.202:8888/' id:'1561880063708057217' remote:'192.168.0.186' command:'/usr/bin/ls' origin:'file://' | CONNECT
Sun, 30 Jun 2019 15:34:23 +0800 | ACCESS | session    | url:'http://192.168.0.202:8888/' id:'1561880063708057217' remote:'192.168.0.186' command:'/usr/bin/ls' origin:'file://' pid:'11249' | DISCONNECT
Sun, 30 Jun 2019 15:34:26 +0800 | ACCESS | session    | url:'http://192.168.0.202:8888/' id:'1561880066921139807' remote:'192.168.0.186' command:'/usr/bin/ls' origin:'file://' | CONNECT
Sun, 30 Jun 2019 15:34:26 +0800 | ACCESS | session    | url:'http://192.168.0.202:8888/' id:'1561880066921139807' remote:'192.168.0.186' command:'/usr/bin/ls' origin:'file://' pid:'11253' | DISCONNECT

 

 

浏览器 console 测试连接,可以看到 ls 命令的输出:

var ws = new WebSocket('ws://ip:port');
ws.onopen = function(event){console.log("CONNECT")};
ws.onmessage = function(event){console.log(event.data)};
ws.onerror = function(event){console.log(event)};

 

mac上安装

https://blog.just4fun.site/websocketd.html

 

websocket 介绍

http://www.ruanyifeng.com/blog/2017/05/websocket.html

转载于:https://www.cnblogs.com/root0/p/11110084.html

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值