lua 收不到服务器发来消息,Lua客户端,Python服务器,本地一切正常,n上超时

所以,我正在编写一个lua mod来绑定Isaac。我制作了一个lua客户机(使用luasocket)和一个python服务器。在

在本地,一切正常,但是当我使用我的公共ip(我在路由器上进行端口转发)测试时,lua客户端在第二次接收时超时。

我不知道是什么原因造成的,日志上写着“CID超时”。在

编辑(忘记添加此项):

奇怪的是,对于python服务器,好像他已经发送了它,因为当我在服务器上添加超时时,只有接收到消息“[RCID]\n”超时。在

以下是lua mod的网络部分:

在local socket = require("socket")

local connectIP = ""

local currentPort = 21666

local loopTimeout = 10

function Network.SendData(data)

if currentBehaviour == Behaviour.CLIENT then

client:send(data.."\n")

end

end

function Network.StartClient()

if currentBehaviour == Behaviour.IDLE then

client = assert(socket.tcp())

client:connect(connectIP,currentPort)

currentBehaviour = Behaviour.CLIENT

client:settimeout(loopTimeout)

local seed,errs = client:receive()

if errs~="timeout" and errs~=nil then

Network.CloseConnection();

Isaac.DebugString("seederror:"..errs);

elseif errs=="timeout" then

Network.CloseConnection();

Isaac.DebugString("timeout at seed");

elseif errs==nil then

Isaac.DebugString("Seed: : "..seed);

Isaac.ExecuteCommand("seed "..seed)

end

local CID,err = client:receive()

if err~="timeout" and err~=nil then

Network.CloseConnection();

Isaac.DebugString("ciderror:"..err);

elseif err=="timeout" then

Network.CloseConnection();

Isaac.DebugString("timeout at CID");

elseif err==nil then

Isaac.DebugString("CID : "..CID);

ClientID = tonumber(CID)

Network.SendData("[RCID]")

end

end

end

这是服务器:

^{pr2}$

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值