Question about setsockname and portforwarding inside local network

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
Akexandre
Prole
Posts: 1
Joined: Sun Apr 12, 2020 6:18 pm

Question about setsockname and portforwarding inside local network

Post by Akexandre »

Hello there :crazy:

I'm posting my question here because I'm trying to find the solution by searching on internet and multiple network forum but I do not understand (maybe it's obvious).
I have a code with server and client and on local machine and it works. Trouble is when I try to have the server on my laptop one (192.168.0.10) and client on my second laptop (192.168.0.11).

Code on server :

Code: Select all

local socket = require('socket')
udp = socket.udp()
udp:setsockname('*', 6731)
udp:settimeout(0)
Code on client :

Code: Select all

local socket = require "socket"
local address, port = "localhost", 6731
udp = socket.udp()
udp:setpeername(address, port)
udp:settimeout(0)
Here localhost refer to ::1 - I try to change both side with 127.0.0.1 it works (logic). When i try to put on server "127.0.0.1" and on client "192.168.0.10" it's not working.

I know that I need to use port forwarding on my router (e.g. apache works well on port 4513) and I added the rule but nothing happens. I assume the issue is before : when on my server side I try to see if 6731 is listening with netstat, I do not see anything (even with firewall fully turned off).

I have to admit, I'm lost and my question is more about network than lua but I'm maybe not the only one and maybe I'm missing something with UDP protocol.

I hope I will have a chance to understand this, I would like to enjoy my game with friends and for now I'm stucK.

Thank you in advance for your precious help, I'm looking forward to have news from you

Cheers :awesome:

Alex
User avatar
ReFreezed
Party member
Posts: 612
Joined: Sun Oct 25, 2015 11:32 pm
Location: Sweden
Contact:

Re: Question about setsockname and portforwarding inside local network

Post by ReFreezed »

Port forwarding does nothing within a local network - it's only for connections from the outside, so that's not the problem. I think setpeername() should take the address you want to connect to and setsockname() should take "*". (My socket knowledge is a little bit rusty.)
Tools: Hot Particles, LuaPreprocess, InputField, (more) Games: Momento Temporis
"If each mistake being made is a new one, then progress is being made."
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], secretsue92 and 119 guests