Page 1 of 2

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

Posted: Mon May 07, 2018 5:15 pm
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 :)

Re: Multiplayer using sock.lua

Posted: Mon May 07, 2018 5:54 pm
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?

Re: Multiplayer using sock.lua

Posted: Mon May 07, 2018 5:58 pm
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.

Re: Multiplayer using sock.lua

Posted: Mon May 07, 2018 6:03 pm
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.

Re: Multiplayer using sock.lua

Posted: Mon May 07, 2018 6:05 pm
by Quôzul
It's not a local IP adress, it starts with 172.xxx.xx.xx :D

Re: Multiplayer using sock.lua

Posted: Mon May 07, 2018 6:17 pm
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.

Re: Multiplayer using sock.lua

Posted: Mon May 07, 2018 6:27 pm
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)

Re: Multiplayer using sock.lua

Posted: Tue May 08, 2018 12:28 am
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?

Re: Multiplayer using sock.lua

Posted: Tue May 08, 2018 12:53 am
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.

Re: Multiplayer using sock.lua

Posted: Tue May 08, 2018 9:53 am
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).