Code: Select all
-- server.lua
local enet = require "enet"
local host = enet.host_create("*:25995")
while true do
local event = host:service(100)
while event do
if event.type == "receive" then
print("Got message: ", event.data, event.peer)
event.peer:send( "pong" )
elseif event.type == "connect" then
print(event.peer, "connected.")
elseif event.type == "disconnect" then
print(event.peer, "disconnected.")
end
event = host:service()
end
end
Code: Select all
-- client.lua
local enet = require "enet"
local host = enet.host_create()
local server = host:connect("the ip and port go here...")
while true do
local event = host:service(100)
while event do
if event.type == "receive" then
print("Got message: ", event.data, event.peer)
event.peer:send( "ping" )
elseif event.type == "connect" then
print(event.peer, "connected.")
event.peer:send( "ping" )
elseif event.type == "disconnect" then
print(event.peer, "disconnected.")
end
event = host:service()
end
end
Am I doing this right? In the server code I specify the ip as "*" which should check all open connections on port 25995 but I get nothing.
Any advice would be greatly appreciated.