Examples from the websockets module我之前提到过:
-- create clIEnt:local websocket = require'websocket'local clIEnt = websocket.clIEnt.copas({timeout=2})-- connect to the server:local ok,err = clIEnt:connect('ws://localhost:12345','echo')if not ok then print('Could not connect',err)end-- send data:local ok = clIEnt:send('hello')if ok then print('msg sent')else print('connection closed')end-- receive data:local message,opcode = clIEnt:receive()if message then print('msg',message,opcode)else print('connection closed')end-- close connection:local close_was_clean,close_code,close_reason = clIEnt:close(4001,'lost interest')
你试过吗?遇到问题?
总结以上是内存溢出为你收集整理的如何使用Lua脚本语言打开Web套接字?全部内容,希望文章能够帮你解决如何使用Lua脚本语言打开Web套接字?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)