so from my knowledge, to achieve connection over the internet, the server needs it's public ip adress/localhost and the client need to connect over that ip adress...
this is the server code
Code: Select all
local sock = require 'sock'
function love.load()
server = sock.newServer("localhost", 22122)
server:on("connect", function(data, client)
local msg = "Hello from the server!"
client:send("hello", msg)
end)
end
function love.update(dt)
server:update()
end
Code: Select all
function love.load()
local serverPublicIp = "125.162.82.41"
client = sock.newClient(serverPublicIp, 22122)
client:on("connect", function(data)
print("Client connected to the server.")
end)
client:connect()
end
function love.update(dt)
client:update()
end
and I tested to change the
Code: Select all
server = sock.newServer("localhost", 22122)
Code: Select all
server = sock.newServer("125.162.82.41", 22122)