Page 1 of 2

Lua Enet IPv6

Posted: Mon Dec 17, 2018 11:05 am
by EliterScripts
Simple question: does Lua Enet support IPv6? If so, can I get some example code just to make sure there is nothing different?

Re: Lua Enet IPv6

Posted: Mon Dec 17, 2018 3:29 pm
by zorg
No, enet doesn't; the socket lib, however, does.

Re: Lua Enet IPv6

Posted: Wed Dec 19, 2018 5:56 am
by EliterScripts
I believe in Internet freedom, and I believe that a major part of true Internet freedom is supporting IPv6 to the fullest obtainable extent, that I must do my part to support IPv6 in this world.

How would I go about replacing my existing code for Lua-enet for code that works with IPv6?

Re: Lua Enet IPv6

Posted: Wed Dec 19, 2018 10:21 am
by zorg
To be fair, enet's reason for not supporting ipv6 has nothing to do with the creator supporting freedom or not, to be honest.

As for replacing, i don't know.

Re: Lua Enet IPv6

Posted: Thu Dec 27, 2018 11:01 pm
by EliterScripts
Like, is there any libraries/solutions that are similar to lua-enet that support IPv6?

Re: Lua Enet IPv6

Posted: Fri Dec 28, 2018 6:45 am
by zorg
yes, the socket library; alternatively, there might be an enet fork that has ipv6, i kinda remember seeing one, but that's not the "lua- branch" either.

Re: Lua Enet IPv6

Posted: Tue Jan 22, 2019 5:11 am
by EliterScripts
Hello,
I have looked further into Luasocket, and I have been able to successfully get a client to connect to the server by looking at some of the client/server examples on the Internet. However, I cannot seem to grasp how it all works.

I am thinking I will use TCP for my game. It will be a very fast-paced game, and my impression is that UDP does not check that the data transmitted is correct, making it not reliable. I am thinking my game's protocol needs to have packets transmitted correctly, because one character wrong could break the entire message.

With that said, I believe that I want to keep the client and server socket open for an extended period of time. However, these example code snippets open the client, send data, receive data, and close the client. I need to program this so that I can handle multiple continuous connections.

From what I understand is that on the server-side, you have server:accept() that creates a new connection (client). However, it does not create a client object for existing client connections that have just sent data to be read. So you must create a table that inserts a client object from server:accept(), set a timeout, then go through the table of clients to check if there is data to read from each.

That makes sense, but what isn't making sense is detecting if a socket is dead/closed or not (from the server). I also don't know if I should try to make a thread for each client, or if I should have 2-5 threads and split the client sockets across just a handful of threads.

Thanks!

Re: Lua Enet IPv6

Posted: Tue Jan 22, 2019 9:23 am
by grump
EliterScripts wrote: Tue Jan 22, 2019 5:11 am my impression is that UDP does not check that the data transmitted is correct, making it not reliable. I am thinking my game's protocol needs to have packets transmitted correctly, because one character wrong could break the entire message.
That impression is not correct. "Not reliable" in the context of UDP does not mean you will receive corrupt data. A UDP packet either arrives intact or not at all. If data gets corrupted in transit, the whole packet is simply dropped.

If that is not acceptable, because you require messages to arrive and in correct order, then TCP is usually the way to go. It's also possible to use both protocols at the same time; you could send vital state changes via TCP, and less important data (e. g. transient position updates) via UDP. It all depends on your game.
That makes sense, but what isn't making sense is detecting if a socket is dead/closed or not (from the server).
What do you mean?

Re: Lua Enet IPv6

Posted: Thu Jan 24, 2019 6:34 pm
by EliterScripts
Okay, now I am having issues when I have multiple clients connected/disconnected/not fully disconnected. Could any of you help me out with this code? The server is run on a separate thread, by the way.

client:
https://gist.github.com/EliterScripts/5 ... 3480d74a7f

server:
https://gist.github.com/EliterScripts/3 ... 601590245b

Re: Lua Enet IPv6

Posted: Thu Jan 24, 2019 8:54 pm
by grump
EliterScripts wrote: Thu Jan 24, 2019 6:34 pm Okay, now I am having issues when I have multiple clients connected/disconnected/not fully disconnected
To increase your chances at getting qualified help, I suggest that you provide a better description of what those issues are, and love file(s) that replicate the issues. Some code snippets won't do it.