Yes, but having trouble with peer-to-peer. Maybe I’m doing something wrong. My Corona app code follows, where init is called once and update is called in an “enterFrame” event listener from another module.
function UdpSocket.init()
udp = socket.udp()
udp:settimeout(0)
udp:setpeername(socket.dns.toip("localhost"), 2278)
--udp:setsockname("\*", 2278)
end
local function peertopeer()
local data, msg = udp:receive()
if not data then
datagram = tostring(msg)
else
datagram = data
end
return datagram
end
function UdpSocket.update()
return peertopeer()
end
Lua send client follows. Keep getting “timeout” in the app on the receive (line 9 above). If I use the commented out setsockname call instead of setpeername, it works, but I want to limit the conversation between the app and one peer.
[code]
local socket = require(“socket”)
local function main()
local udp = socket.udp()
local host, port = “localhost”, 2278
local ip = socket.dns.toip(host)
udp:settimeout(0)
local cnt = 1
while true do
udp:sendto("message " … cnt, ip, 2278)
cnt = cnt + 1
end
end
main()
[/code] [import]uid: 58455 topic_id: 22228 reply_id: 88696[/import]