Corona Labs-服务器在构建时未接收数据

时间:2019-01-07 22:49:10

标签: lua corona

我正在与Corona Labs中的Lua Socket进行UDP网络连接。我有一个客户端通过发送字符串连接到服务器。在我构建应用程序时,服务器会接收字符串并正确连接,然后使用“运行应用程序”提示运行它。但是,当我通过可执行文件运行它时,它不会接收。

当我通过“运行应用程序”选项从可执行文件和服务器运行客户端时,它将起作用。但是,另一种方法不起作用。在电晕模拟器中也无法使用。

            --Server

            local ipTable = {}
            local portTable = {}
            local udpVar = socket.udp()
            udpVar:settimeout(1/30)
            udpVar:setsockname("*", 46362)

            local function addClients()
                local data, ip, port = udpVar:receivefrom()
                print(data)
                if data == "drumline" then
                    print(data)
                    table.insert(ipTable, ip)
                    table.insert(portTable, port)
                end
            end
            Runtime:addEventListener("enterFrame", addClients)



            --Client

            local udpVar = socket.udp()
            udpVar:settimeout(1/30)

            local function connectTap()
                udpVar:setpeername(ipTextVar, 46362)
                print(udpVar)
                udpVar:send("drumline")
            end
            connectButton:addEventListener("tap", connectTap)

我希望服务器打印该字符串,但是仅当我通过“运行应用程序”运行它时才显示,而不是通过可执行文件运行时。

0 个答案:

没有答案