hi
version 0.7 i got working fine.
but version 1.0 is very different, and i just can't get it to work at all
globals :
server code :
Code: Select all
function StartServer()
server = lube.udpServer()
server:listen(_port)
server.callbacks.connect = onConnect
server.callbacks.recv = onReceive
server.handshake = "Hi!"
print("created")
end
client code :
Code: Select all
function StartClient()
client = lube.udpClient()
client.handshake = "Hi!"
client.callbacks.recv = Receive
success, er = client:connect(_ip, _port)
print("success : " .. tostring(success))
return success
end
regardless if the server is running StartClient() is always successful - I assume this is due to the nature of udp being connectionless ? (maybe?). Or should it only connect to a port that is being "listened" on ? If this is so.. then I have no idea why/how it always connects successfully.
the main problem is, in the server code i have
Code: Select all
function onConnect(id)
print("Connected : " .. id)
server:send("hi")
end
"Connected : ip:port" gets printed to my log so that's all good.
but server:send("hi") is NEVER received by the client
inside LUBE.lua, it fails here
Code: Select all
function udpClient:_receive()
local data, ip, port = self.socket:receivefrom()
print(data)
if ip == self.host and port == self.port then
return data
end
print("data " .. tostring(data))
print("ip " .. ip)
print("port " .. tostring(port))
print("self host : "..self.host)
print("self port : "..self.port)
return false, "Unknown remote sent data."
end
console window:
nil
data nil
ip timeout
port nil
self host : 127.0.0.1
self port : 18025
What am I missing here ?