LUBE (Networking Library)

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
FinalSin
Prole
Posts: 16
Joined: Tue Dec 14, 2010 3:09 pm

Re: LUBE (Networking Library)

Post by FinalSin »

Will do! Thanks man. :)

EDIT - Good lord, UDP holepunch sounds complicated. I'll try port opening first, if that's possible.

Of course, it's not going to be possible in general, so if anyone has successfully implemented UDP holepunch with LUBE, let me know.
Deif
Prole
Posts: 12
Joined: Sun Mar 06, 2011 10:01 pm

Re: LUBE (Networking Library)

Post by Deif »

Just thought I'd chip in as there's some stuff that's not really explained and any new people that come across this might get a bit confused as to the capability of the library. I've also cleaned up the wiki a bit with the functions that were missing and/or incorrect.

The library does support nested tables, you just have to call lube.bin:setseperators. For example, I used it to pack up each player object on screen, then packed the variables I wanted to send again for each player object. I'll just put a little thing from my code here that I did as an example. So when I packed, I used char 1 and 2 first, then packed again with 30 and 31 which are smiley faces and triangles (if anyone wants to know).

Code: Select all

function Client.receive(data)

	lube.bin:setseperators(string.char(30),string.char(31))
	local datatable = lube.bin:unpack(data)
	local playertable = {}

	for n,p in pairs(datatable) do
		lube.bin:setseperators(string.char(1),string.char(2))
		playertable[n] = lube.bin:unpack(p)

		-- Now everything is unpacked you call your own function to do something with it
		playerobject[n]:updatedata(playertable[n])

	end	
end

Awesome library btw, once you know how it works, it's dead easy to use. :awesome:
User avatar
ZenX2
Citizen
Posts: 89
Joined: Wed Nov 17, 2010 5:35 am

Re: LUBE (Networking Library)

Post by ZenX2 »

I'm having some trouble with lube. ( :crazy: )
My problem involves sending data from server to client with udp.
At first, on sending it was convinced that self.clients was nil, but I got around this because I'm using my own method of tracking ips/ports.
Now, it thinks self.socket is nil. If it means anything, this is happening after server creation.
Deif
Prole
Posts: 12
Joined: Sun Mar 06, 2011 10:01 pm

Re: LUBE (Networking Library)

Post by Deif »

Might be worth including your code, hard to see where you're going wrong otherwise.
User avatar
ZenX2
Citizen
Posts: 89
Joined: Wed Nov 17, 2010 5:35 am

Re: LUBE (Networking Library)

Post by ZenX2 »

Basically, I'm using the example at the top of page 22.
Deif
Prole
Posts: 12
Joined: Sun Mar 06, 2011 10:01 pm

Re: LUBE (Networking Library)

Post by Deif »

Well the example didn't include any sending so I'm still going to need your code to see how to fix it.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: LUBE (Networking Library)

Post by bartbes »

Nor does it contain that custom code of yours, which is the interesting part ;).
User avatar
Lap
Party member
Posts: 256
Joined: Fri Apr 30, 2010 3:46 pm

Re: LUBE (Networking Library)

Post by Lap »

I can't really fix this problem since i don't experience it, but it goes something like this:

Player starts a TCP server and joins it and then for whatever reason he ends the connection ungracefully (i.e. Love crashes). When trying to start the program and create another TCP server it fails to open a socket since the last one still hasn't closed. The player needs to wait 10-30 seconds or so for that last socket to close. This was reported on Ubuntu I believe and I don't personally have any problems on Win 7.

There any setting I can change to fix this?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: LUBE (Networking Library)

Post by bartbes »

You could add this before line 458 (that's lube.server.tcp:startserver)

Code: Select all

self.socket:setoption("reuseaddr", true)
User avatar
Lap
Party member
Posts: 256
Joined: Fri Apr 30, 2010 3:46 pm

Re: LUBE (Networking Library)

Post by Lap »

I haven't had testers report back yet, but I actually already added that same line, but using 'false' because:

http://w3.impa.br/~diego/software/luasocket/socket.html

says that all sockets bound already have that option set to true. Figured I'd change it and hope for better results. Did you actually mean false, or does LUBE somehow not have it automatically set to true?
Post Reply

Who is online

Users browsing this forum: No registered users and 152 guests