Multiplayer using sock.lua | Can't host a server

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.
User avatar
Quôzul
Prole
Posts: 15
Joined: Mon Apr 16, 2018 5:03 pm
Location: France
Contact:

Multiplayer using sock.lua | Can't host a server

Post by Quôzul »

Hello,
I'm trying to create a mutiplayer game using the library Sock.lua, this is working in local but I can't connect to the server through my public IP :huh:
Even with the given exemple Pong it isn't working...

I've just done that:

Code: Select all

client = sock.newClient("my IP adress", 22122)
Of course, I opened the necessary ports.
And sorry if my english is bad :)
Last edited by Quôzul on Tue May 08, 2018 11:15 am, edited 1 time in total.
User avatar
Sir_Silver
Party member
Posts: 286
Joined: Mon Aug 22, 2016 2:25 pm
Contact:

Re: Multiplayer using sock.lua

Post by Sir_Silver »

Gonna have to supply some more information. Is there an error? If so, what is the error, if not, what exactly happens? Can you upload a .love of your game?
User avatar
Quôzul
Prole
Posts: 15
Joined: Mon Apr 16, 2018 5:03 pm
Location: France
Contact:

Re: Multiplayer using sock.lua

Post by Quôzul »

Sir_Silver wrote: Mon May 07, 2018 5:54 pm Gonna have to supply some more information. Is there an error? If so, what is the error, if not, what exactly happens? Can you upload a .love of your game?
There is no errors that's the problem, it's just seing "connecting" for a while and then "disconnected".
I attached my .love files (my code is maybe a bit messy) but it does not work as well with the exemple from the github repository of sock.lua.
Attachments
client.love
(3.27 KiB) Downloaded 214 times
server.love
(15.59 KiB) Downloaded 205 times
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Multiplayer using sock.lua

Post by zorg »

Does "your IP address" start with 127 or 192.168?
If so, that's local, and the reason why it won't work, you'd need your public IP address.
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
Quôzul
Prole
Posts: 15
Joined: Mon Apr 16, 2018 5:03 pm
Location: France
Contact:

Re: Multiplayer using sock.lua

Post by Quôzul »

It's not a local IP adress, it starts with 172.xxx.xx.xx :D
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Multiplayer using sock.lua

Post by grump »

Quôzul wrote: Mon May 07, 2018 6:05 pm It's not a local IP adress, it starts with 172.xxx.xx.xx :D
172.16.x.x to 172.31.x.x? That's a private IP address.
User avatar
Quôzul
Prole
Posts: 15
Joined: Mon Apr 16, 2018 5:03 pm
Location: France
Contact:

Re: Multiplayer using sock.lua

Post by Quôzul »

grump wrote: Mon May 07, 2018 6:17 pm
Quôzul wrote: Mon May 07, 2018 6:05 pm It's not a local IP adress, it starts with 172.xxx.xx.xx :D
172.16.x.x to 172.31.x.x? That's a private IP address.
172.186.x.x I made servers for other games to play with my friends and it worked

EDIT:
My IP is starting by 176.186.x.x (I don't know it by heart) :nyu: (I put the right IP in my game, I was just wrong here)
Last edited by Quôzul on Tue May 08, 2018 9:21 am, edited 1 time in total.
User avatar
Sir_Silver
Party member
Posts: 286
Joined: Mon Aug 22, 2016 2:25 pm
Contact:

Re: Multiplayer using sock.lua

Post by Sir_Silver »

Are other people able to connect but not yourself? If I recall correctly, I've had this same problem, (others can connect to my server but not me) and what would work for me was to use "localhost" as the ip I believe. Give that a shot perhaps?
User avatar
Beelz
Party member
Posts: 234
Joined: Thu Sep 24, 2015 1:05 pm
Location: New York, USA
Contact:

Re: Multiplayer using sock.lua

Post by Beelz »

IIRC, you cannot connect to a server on the same machine with a public IP address, if that makes sense. Any other IP can connect to you, but you have to connect to localhost or 127.0.0.1 if the server is on the same machine as the program trying to access it.

Code: Select all

if self:hasBeer() then self:drink()
else self:getBeer() end
GitHub -- Website
KayleMaster
Party member
Posts: 234
Joined: Mon Aug 29, 2016 8:51 am

Re: Multiplayer using sock.lua

Post by KayleMaster »

You can't connect with your public ip because your router probably doesn't support hairpinning. (if you are connecting from the same network)

Hairpinning is where a machine on the LAN is able to access another machine on the LAN via the external IP address of the LAN/router (with port forwarding set up on the router to direct requests to the appropriate machine on the LAN).
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 37 guests