_ccgi websocket">
赞
踩
<!DOCTYPE html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <meta name="format-detection" content="telephone=no"> <meta charset="UTF-8"> <style> </style> </head> <body> <input type="text"> <button>测试</button> <div></div> </body> <script> var input=document.querySelector('input') var button=document.querySelector('button') var div=document.querySelector('div') //创建websocket对象 // var socket=new WebSocket('ws://echo.websocket.org') var socket=new WebSocket('ws://192.168.32.190:9999') //添加连接成功事件监听 socket.addEventListener('open',()=>{ div.innerHTML='连接成功' }) socket.addEventListener('message',(msg)=>{ console.log(msg) div.append(msg.data) }) button.addEventListener('click',()=>{ var value=input.value socket.send(value) console.log("测试") }) </script> </html>
源码:
https://github.com/wexiangis/websocket_for_linux
博客参考:
https://blog.csdn.net/SGuniver_22/article/details/74273839?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-9.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromBaidu-9.control
抓包参考博客:
https://blog.csdn.net/holandstone/article/details/47026213
select()函数详解:
https://blog.csdn.net/hmxz2nn/article/details/79777372?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522160731167419724839520346%2522%252C%2522scm%2522%253A%252220140713.130102334…%2522%257D&request_id=160731167419724839520346&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2alltop_click~default-1-79777372.nonecase&utm_term=select()&spm=1018.2118.3001.4449
https://blog.csdn.net/lingfengtengfei/article/details/12392449
优秀博客文章:
https://blog.csdn.net/xxdddail/article/details/19070149
http://www.2cto.com/kf/201210/161006.html
TCP协议详解:
https://blog.csdn.net/miao309410364/article/details/50240173
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。