Networking with lua? Making online games?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
nikneym
Citizen
Posts: 56
Joined: Sat Mar 09, 2013 1:22 pm
Contact:

Networking with lua? Making online games?

Post 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?
User avatar
Azhukar
Party member
Posts: 478
Joined: Fri Oct 26, 2012 11:54 am

Re: Networking with lua? Making online games?

Post by Azhukar »

User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Networking with lua? Making online games?

Post 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.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
nikneym
Citizen
Posts: 56
Joined: Sat Mar 09, 2013 1:22 pm
Contact:

Re: Networking with lua? Making online games?

Post 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?
User avatar
zorg
Party member
Posts: 3468
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Networking with lua? Making online games?

Post 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)
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
incognito_mage
Prole
Posts: 15
Joined: Mon Nov 06, 2017 12:38 pm

Re: Networking with lua? Making online games?

Post 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.
What's this? What's this? There's violas everywhere!
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 13 guests