connection over the internet using sock.lua
Posted: Tue Sep 24, 2019 9:17 am
I'm using sock.lua library networking.. https://github.com/camchenry/sock.lua
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
and this is the client code
I tested both code on the same machine simultaneously, there is no error.. nothing.. the message was never transferred
and I tested to change the
to
it still wont work, I have no idea what went wrong, I need to know how to connect to other machine over the internet
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)