Page 24 of 34

Re: LUBE (Networking Library)

Posted: Sun Jan 30, 2011 9:30 pm
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.

Re: LUBE (Networking Library)

Posted: Sun Mar 06, 2011 11:17 pm
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:

Re: LUBE (Networking Library)

Posted: Sun Mar 13, 2011 3:27 am
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.

Re: LUBE (Networking Library)

Posted: Sun Mar 13, 2011 11:36 am
by Deif
Might be worth including your code, hard to see where you're going wrong otherwise.

Re: LUBE (Networking Library)

Posted: Sun Mar 13, 2011 6:03 pm
by ZenX2
Basically, I'm using the example at the top of page 22.

Re: LUBE (Networking Library)

Posted: Mon Mar 14, 2011 6:46 pm
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.

Re: LUBE (Networking Library)

Posted: Mon Mar 14, 2011 10:21 pm
by bartbes
Nor does it contain that custom code of yours, which is the interesting part ;).

Re: LUBE (Networking Library)

Posted: Sun Apr 24, 2011 12:01 pm
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?

Re: LUBE (Networking Library)

Posted: Sun Apr 24, 2011 12:23 pm
by bartbes
You could add this before line 458 (that's lube.server.tcp:startserver)

Code: Select all

self.socket:setoption("reuseaddr", true)

Re: LUBE (Networking Library)

Posted: Sun Apr 24, 2011 12:36 pm
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?