## 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
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

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
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.
Sir_Silver
Party member
Posts: 286
Joined: Mon Aug 22, 2016 2:25 pm
Contact:

### Re: Multiplayer using sock.lua

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

### Re: Multiplayer using sock.lua

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
server.love
zorg
Party member
Posts: 3091
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

### Re: Multiplayer using sock.lua

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

### Re: Multiplayer using sock.lua

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

### Re: Multiplayer using sock.lua

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

### Re: Multiplayer using sock.lua

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
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) (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.
Sir_Silver
Party member
Posts: 286
Joined: Mon Aug 22, 2016 2:25 pm
Contact:

### Re: Multiplayer using sock.lua

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?
Beelz
Party member
Posts: 234
Joined: Thu Sep 24, 2015 1:05 pm
Location: New York, USA
Contact:

### Re: Multiplayer using sock.lua

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: 223
Joined: Mon Aug 29, 2016 8:51 am

### Re: Multiplayer using sock.lua

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).

### Who is online

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