Lua-enet, Which Ip to put in.
Posted: Thu Oct 08, 2015 1:34 am
Hi I made a recent post about how when I dragged the window my server crashed up until now, I've been working with this address :
'localhost:17771'
I forwarded the port 17771 on my router for the the ip range of 192.168.0.100 to 192.168.0.110.
Know I want to play with my friends and I know they cant use this ip, so how do I determine which ip i have to put in there so taht they can join me.
Also if the code helps Here's the server:
And here's the client:
'localhost:17771'
I forwarded the port 17771 on my router for the the ip range of 192.168.0.100 to 192.168.0.110.
Know I want to play with my friends and I know they cant use this ip, so how do I determine which ip i have to put in there so taht they can join me.
Also if the code helps Here's the server:
Code: Select all
require('enet')
sentdata = 0
recieveddata = 0
count = 2
local host = enet.host_create('IP ADDRESS:17771')
function love.update(dt)
local event = host:service(100)
if event then
if event.type == "receive" then
print("Got message: ", event.data, event.peer)
recieveddata = event.data
elseif event.type == "connect" then
else
print("Got event", event.type, event.peer)
end
end
host:broadcast(sentdata)
end
function love.draw()
love.graphics.setColor(255, 255, 255)
love.graphics.print('Recieved Data: '..recieveddata..' Data To Be Sent: '..sentdata,100,100)
end
Code: Select all
require('enet')
require('socket')
count = 0
local host = enet.host_create()
local server = host:connect('woops:17771')
stillonline = ""
flushcounter = 0
function love.update(dt)
myip = socket.dns.toip(socket.dns.gethostname())
event = host:service(50)
flushcounte = flushcounter + 1
s = socket.udp()
s:setpeername("74.125.115.104",80)
ip, _ = s:getsockname()
if event then
if event.type == "receive" then
print("Got message: ", event.data)
elseif event.type == "disconnect" then
stillonline = event.type
elseif event.type == "connect" then
stillonline = event.type
end
end
if flushcounter > 50 then -- Flush each (50*dt seconds)
host:flush()
end
count = count + 100
host:broadcast(count)
end
function love.draw()
love.graphics.setColor(255, 255, 255)
love.graphics.print( 'Count: '..count.." DEAD DATA".."\n"..stillonline.."\n".."Dns.toip :"..myip.."\n".."Local IP :"..ip,100,100)
end