Networking, Help!

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
adam_fowler
Prole
Posts: 1
Joined: Sun Apr 24, 2016 10:54 pm

Networking, Help!

Post by adam_fowler »

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:

Code: Select all

server = assert(socket.udp())
server:settimeout(0)
server:setoption( "dontroute", true )
Then on timer loop this code is run

Code: Select all

server:sendto(Address, "127.192.1.1", Port)
Address is the Public IP of the hosting machine, Also Port is 28787

Here is the client code:

Code: Select all

listen = socket.udp()
listen:setsockname("127.192.1.1",Port)

listen:settimeout(0)
makes the socket to look for host

Code: Select all

repeat
    local data, ip, port = listen:receivefrom()
    if data then
        IP = data
    end
until IP
listen:close()
Loops until it finds the host and receives the IP of said host and connects with TCP
Any help would be greatly appreciated.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests