When you have connected you can use lube.server/client.socket:getsockname() to get your local ip and port.
If you need your external IP you should look at something like STUN or some other form of UDP hole punching. You could also try to find a site like whatismyip.com and parse it's return data (check out http://www.whatismyip.com/automation/n09230945.asp).
EDIT: Do note that the last method doesn't give you a port, so there's no way of knowing you can actually reach the host behind the NAT.
LUBE (Networking Library)
Re: LUBE (Networking Library)
Hey.
Hey.
Re-upload it.
Hey.
Re-upload it.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: LUBE (Networking Library)
Easy dude, easy, I'm releasing a new version.. soon.
Re: LUBE (Networking Library)
...GIEF.bartbes wrote:Easy dude, easy, I'm releasing a new version.. soon.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: LUBE (Networking Library)
Forgot to tell you guys, but I updated it yesterday .
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: LUBE (Networking Library)
I don't suppose there's anyone here with networking experience and some free time, who would like to help me implement multiplayer functionality in my current project? Not just for working with Lube, but also with the multiplayer architecture (stuff like "who sends what data to whom", "how do I ensure I only send changed data", and so on).
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Re: LUBE (Networking Library)
All I can say is that you should have the server do as much as possible to minimize cheating.
Good bye.
Re: LUBE (Networking Library)
-- EDIT 2 --
After some testing, it is indeed the packet size that is my current problem. Base64 quick fix seems to work plenny good.
-- END --
-- EDIT --
I'm noticing packets failing to be read properly every now and then, even using TCP. That wasn't happening before I switched to a different packeting system (after I monkeyed with LUBE). Perhaps there is more to fixing this than I thought. Also, perhaps the packets I want to send are too big.
-- END --
Hey, I noticed that the current version of LUBE only supports one level of table nesting due to improper string handling. I hacked together a quick fix using LuaSocket's mime.b64/unb64 to make sure string data didn't overlap with the separator characters. It makes the packets a bit fatter, but having good support for strings/table-nesting could be worth it. Here's the three lines I added/modified:
After some testing, it is indeed the packet size that is my current problem. Base64 quick fix seems to work plenny good.
-- END --
-- EDIT --
I'm noticing packets failing to be read properly every now and then, even using TCP. That wasn't happening before I switched to a different packeting system (after I monkeyed with LUBE). Perhaps there is more to fixing this than I thought. Also, perhaps the packets I want to send are too big.
-- END --
Hey, I noticed that the current version of LUBE only supports one level of table nesting due to improper string handling. I hacked together a quick fix using LuaSocket's mime.b64/unb64 to make sure string data didn't overlap with the separator characters. It makes the packets a bit fatter, but having good support for strings/table-nesting could be worth it. Here's the three lines I added/modified:
Code: Select all
-- ADDED BY KYNAN
mime = require "mime"
-- END
Code: Select all
function lube.bin:packvalue(i, v)
local id = ""
local typev = type(v)
if typev == "string" then id = "S"
elseif typev == "number" then id = "N"
elseif typev == "boolean" then id = "B"
elseif typev == "userdata" then id = "U"
elseif typev == "nil" then id = "0"
else error("Type " .. typev .. " is not supported by lube.bin") return
end
-- MODIFIED BY KYNAN
return tostring(id .. lube.bin.one .. i .. lube.bin.one .. (mime.b64(tostring(v))) .. lube.bin.null)
--return tostring(id .. lube.bin.one .. i .. lube.bin.one .. tostring(v) .. lube.bin.null)
-- END
end
Code: Select all
function lube.bin:unpackvalue(s)
local id = s:sub(1, 1)
s = s:sub(3)
local len = s:find(lube.bin.one)
local i = s:sub(1, len-1)
i = tonumber(i) or i
-- MODIFIED BY KYNAN
local v = (mime.unb64(s:sub(len+1)))
--local v = s:sub(len+1)
-- END
if id == "N" then v = tonumber(v)
elseif id == "B" then v = (v == "true")
elseif id == "0" then v = nil
end
return i, v
end
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: LUBE (Networking Library)
Oh, but it's not a bug (nor a feature), the packing is more like an example than something for production use.
About the packet size, the limit should be 8192.
About the packet size, the limit should be 8192.
Re: LUBE (Networking Library)
Yeah. I wasn't limiting my packets properly. I'll just split them up when they get too big.
Who is online
Users browsing this forum: No registered users and 1 guest