Networking over wifi

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
PGUp
Party member
Posts: 105
Joined: Fri Apr 21, 2017 9:17 am

Networking over wifi

Post by PGUp »

my computer is the server and my phone is the client, both love installed, how? I'm using enet, device dont seem to connect
-
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Networking over wifi

Post by ivan »

Might work if you setup your wifi as a local network where each device has a unique IP.
It won't work if you try to connect over the internet through wifi.
PGUp
Party member
Posts: 105
Joined: Fri Apr 21, 2017 9:17 am

Re: Networking over wifi

Post by PGUp »

ivan wrote: Sun May 19, 2019 1:56 pm Might work if you setup your wifi as a local network where each device has a unique IP.
It won't work if you try to connect over the internet through wifi.
I know, but how? can you give me a simple example using enet? like from my mobile device to computer? i've tried using this method
https://love2d.org/wiki/lua-enet, it didnt work though

server

Code: Select all

local enet = require "enet"
local host = enet.host_create("0.0.0.0:65921")
love.window.setTitle("Server")
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
client (my phone)

Code: Select all

local enet = require "enet"
local host = enet.host_create()
local server = host:connect("0.0.0.0:65921")
love.window.setTitle("client")
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
the error from my phone (client)

Code: Select all

Error

Syntax error: main.lua:6: '=' expected near 'local'
the error doesnt make sense
-
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 58 guests