I'm trying to work with UDP sockets on Android.
The following code works very well in the Windows version.
Do you have some suggestions for porting the code to Android?
Thank you,
Pier Andrea.
Code: Select all
local socket = require "socket"
local address, port = "localhost", 12345
local datagram = ""
local myip = socket.dns.toip(socket.dns.gethostname())
function love.load()
udp = socket.udp()
udp:settimeout(0)
udp:setsockname(myip, 12345)
love.graphics.setFont(love.graphics.newFont(24))
love.graphics.setBackgroundColor(1, 1, 1)
love.graphics.setColor(0, 0, 1)
end
function love.update()
local data, msg = udp:receive()
if data then
datagram = data
end
end
function love.draw()
love.graphics.print(datagram, 10, 10)
end
function love.quit()
udp:close()
end