Peer-to-peer UDP supported?

I tried a simple UDP peer-to-peer test from one simulator to another and nothing is getting put on the socket for reading.

Then I saw this. If true, I think I’m hosed on a project I want to build, where Corona SDK app talks to a 3rd party device over UDP.

http://developer.anscamobile.com/forum/2011/09/24/local-multiplayer-or-pubnub-alternative

“Corona SDK doesn’t support peer-to-peer networking from what I can tell.” [import]uid: 58455 topic_id: 22228 reply_id: 322228[/import]

did you try using louasockets?

see luasockets, and documentation http://w3.impa.br/~diego/software/luasocket/

corona sdk supports full lua sockets…

c
[import]uid: 24 topic_id: 22228 reply_id: 88683[/import]

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]

Hmmm…udp:setsockname(socket.dns.toip(“localhost”), 2278) works. That’s great, but I wonder how this is different from setpeername?

I think I need to read more about UDP and luasockets. [import]uid: 58455 topic_id: 22228 reply_id: 88706[/import]