Page 1 of 1
Networking with lua? Making online games?
Posted: Wed Nov 08, 2017 8:58 pm
by nikneym
Same question with topic name. I'm using lua and löve for a loong time and I made really basic games. But now, I got really big idea and it has to be online. Of course I wanna do it with löve again but I need to start from somewhere, so how can I make an online game?
Re: Networking with lua? Making online games?
Posted: Wed Nov 08, 2017 9:35 pm
by Azhukar
Re: Networking with lua? Making online games?
Posted: Wed Nov 08, 2017 9:47 pm
by zorg
enet if you're fine with only ipv4,
luasocket if you need ipv6 for some reason,
Löve doesn't have a solution for SSL/HTTPS support for now, you'll need an external library for that if you'd want to use that.
Re: Networking with lua? Making online games?
Posted: Thu Nov 09, 2017 4:37 am
by nikneym
Thank you for your answers but one last question. I need a local network to try lua enet and luasocket. Are local networks making from xampp like programs?
Re: Networking with lua? Making online games?
Posted: Thu Nov 09, 2017 7:57 am
by zorg
You can run both server and client on the same machine using the loopback interface most commonly known as 127.0.0.1, just assign them different ports. (minor issues may arise, like you'll be unable to see if your code can work under conditions where other network devices like NATs or firewalls, etc. are between the endpoints)
Re: Networking with lua? Making online games?
Posted: Thu Nov 09, 2017 10:19 am
by incognito_mage
(Anyone correct me if I say something wrong)
You probably want a client server architecture.
As long as the clients don't need to talk to each other without talking to the server, for example for file transfer, your client won't have a dedicated port. Your server will have a dedicated port, known to the clients beforehand. The client will connect to that address:port at startup and a client port will be generated automatically by the OS. You don't usually need to think about that port.
Xampp installs apache for you, which is a server usually used for HTTP (for example for serving a forum such as this one), but you are probably going to write a server yourself using either lua or another language. HTTP would add way too much overhead if you wanted to make very many requests (csgo usually uses 64/128 requests per second), so you need to come up with your own protocol.
The main difference between having your server on a VPS in a server farm away from your client, and having both client and server on the same machine, is that with a single machine you will get <1ms latency between client and server, while with a remote server you will get at least a couple ms but more likely >20ms. You can't rely on every command you send getting there right away, and you have to account for the fact that once in a while a packed will get lost and your command will not get there at all.
To give an example, If I wanted to play a game with servers in north america, from Europe, I would probably get >100ms ping, and even if I had the best connection on earth, I couldn't get less than 50ms unless that connection somehow sent information faster than the speed light!
... after typing this out I realized you might know already everything I've written, haha.