Networking, Help!
Posted: Sun Apr 24, 2016 11:56 pm
Hi, I am trying to make my Love2d Network Multiplayer. I have it working with a UDP broadcast, sending IP of host them clients detect the broadcast and connect with a TCP connection to the host. I have it working if I run two instances on my machine (one host, one client), however I cannot get it to see and connect to host when run over Internet or even over the LAN between two computers
Here is the UDP server code:
Then on timer loop this code is run
Address is the Public IP of the hosting machine, Also Port is 28787
Here is the client code:
makes the socket to look for host
Loops until it finds the host and receives the IP of said host and connects with TCP
Any help would be greatly appreciated.
Here is the UDP server code:
Code: Select all
server = assert(socket.udp())
server:settimeout(0)
server:setoption( "dontroute", true )
Code: Select all
server:sendto(Address, "127.192.1.1", Port)
Here is the client code:
Code: Select all
listen = socket.udp()
listen:setsockname("127.192.1.1",Port)
listen:settimeout(0)
Code: Select all
repeat
local data, ip, port = listen:receivefrom()
if data then
IP = data
end
until IP
listen:close()
Any help would be greatly appreciated.