Skip to content

Instantly share code, notes, and snippets.

@udoprog
Last active December 12, 2015 04:59
Show Gist options
  • Save udoprog/4718743 to your computer and use it in GitHub Desktop.
Save udoprog/4718743 to your computer and use it in GitHub Desktop.
example network support in love
-- code for love.network can be found at https://bitbucket.org/udoprog/love-network
function socketError(s, reason)
print("socket error: " .. reason)
end
function socketRead(s, data)
print("socket read: " .. data)
end
function socketState(s, state)
print("socket state: " .. state)
if state == "connected" then
s:send("Oh hi, nice to see you again!\n")
else
s:connect("localhost", "1234")
end
end
function love.load()
s = love.network.newTcpSocket()
s:setCallbacks(socketRead, socketError, socketState)
s:connect("localhost", "1234")
end
function love.draw()
love.graphics.print("Hello World", 10, 10)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment