如何使用Lua脚本语言打开Web套接字?

如何使用Lua脚本语言打开Web套接字?,第1张

概述作为初学者,我想在基于 Linux的服务器上使用Lua打开一个Web套接字.此服务器应允许 Android客户端连接到它.你能给我一些用Lua打开网络插座的示例代码吗? 两个星期前你已经回答了同样的问题: LUA Script – web socket communication.你看过lua-websockets吗?你有什么尝试?什么不起作用? Examples from the websock 作为初学者,我想在基于 Linux的服务器上使用Lua打开一个Web套接字.此服务器应允许 Android客户端连接到它.你能给我一些用Lua打开网络插座的示例代码吗?解决方法 两个星期前你已经回答了同样的问题: LUA Script – web socket communication.你看过lua-websockets吗?你有什么尝试?什么不起作用?

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套接字?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/langs/1219874.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-05
下一篇 2022-06-05

发表评论

登录后才能评论

评论列表(0条)

保存