02-28-2011, 03:59 AM
Here's an example:
Code:
local TCPLink = {}
TCPLink.__index = TCPLink
function TCPLink:new()
local t = {}
setmetatable(t, TCPLink)
local w = Lua__cTCPLink:new_local() -- new_local = Deleted by garbage collector
tolua.setpeer(w, t)
w:tolua__set_instance(w)
return w
end
TCP = TCPLink:new()
if( TCP:Connect("www.mc-server.org", 80) == true ) then
Log("Sending message")
TCP:SendMessage("GET http://www.mc-server.org/\n")
end
function TCPLink:ReceivedData( Data, Size )
Log("Received data: " .. Size )
String = string.sub( Data, 0, Size )
Log( String )
end