local socket = require "socket"
local Scheduler = cc.Director::getInstance():getScheduler()
local EventMgr = require "EventMgr " --引入自己写的时间分发器,请阅读我的另一篇文章:https://blog.csdn.net/zhang1461376499/article/details/109843025
--下面几个变量是cocos socket组件底层返回的错误码,文件位置在external/lua/luasocket/wsocket.c
local STATUS_CLOSED = "closed"
local STATUS_NOT_CONNECTED = "Socket is not connected"
local STATUS_ALREADY_CONNECTED = "already connected"
local STATUS_ALREADY_IN_PROGRESS = "Operation already in progress"
local STATUS_TIMEOUT = "timeout"
local SOCKET_TICK_INTERNAL = 1 / 60 --socke刷新时间
local SOCKET_CONNECT_TIMEOUT = 5 --重连过期时间
local SOCKET_RECEIVE_MODE = "*a" --接收方式
local
cocos2dx-lua 网络数据篇(socket)网络连接 代码举例(详细)
最新推荐文章于 2024-02-15 09:14:44 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)