Questions about Networking with UDP Tutorial

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
BruceTheGoose
Citizen
Posts: 76
Joined: Sat Sep 20, 2014 2:54 pm

Questions about Networking with UDP Tutorial

Post by BruceTheGoose »

I followed the instructions of the tutorial "Networking with UDP"

https://love2d.org/wiki/Tutorial:Networking_with_UDP

I tried it and it worked. I managed to connect a server and some clients within the same computer. However, as soon as I tried connecting to a server from another computer, I get the error: "Network Error: Refused". The same error occurs even if a server is open or not. I'm running the server file on my Desktop and the client file on my laptop. Any idea why I can't connect from different computers? I am new to the concept of networking and some insight could really be helpful.
"I don't know."
User avatar
pgimeno
Party member
Posts: 3688
Joined: Sun Oct 18, 2015 2:58 pm

Re: Questions about Networking with UDP Tutorial

Post by pgimeno »

You're supposed to change this part. Did you? Did you enter the IP of the machine as address?

Code: Select all

-- the address and port of the server
local address, port = "localhost", 12345
User avatar
BruceTheGoose
Citizen
Posts: 76
Joined: Sat Sep 20, 2014 2:54 pm

Re: Questions about Networking with UDP Tutorial

Post by BruceTheGoose »

Ahhhhh makes sense. Could I obtain this information via cmd?
"I don't know."
User avatar
pgimeno
Party member
Posts: 3688
Joined: Sun Oct 18, 2015 2:58 pm

Re: Questions about Networking with UDP Tutorial

Post by pgimeno »

I haven't used Windows since XP, so some other member may be able to offer better help. In XP, you found the IP of your machine by opening a console terminal and running ipconfig /all

In Linux, you do that opening a terminal and running /sbin/ifconfig, and looking for the IP of the ethXXX interface.

In Mac, I don't know, but it's possible that the same as in Linux works.
User avatar
BruceTheGoose
Citizen
Posts: 76
Joined: Sat Sep 20, 2014 2:54 pm

Re: Questions about Networking with UDP Tutorial

Post by BruceTheGoose »

Last question, If i wanna display the client's ping speed. Is this possible via lua socket?
"I don't know."
User avatar
Tjakka5
Party member
Posts: 243
Joined: Thu Dec 26, 2013 12:17 pm

Re: Questions about Networking with UDP Tutorial

Post by Tjakka5 »

While luasocket doesn't have a inbuilt 'ping' function (As far as I know), it's pretty easy to code it in yourself.

All you have to do is the following:
Send a 'ping' command to the server, and store the current time (love.timer.getTime) somewhere.
Server side, send 'pong' back when it receives 'ping'.
Client side, when it receives 'pong', get the current time again, subtract the previous time, and divide it by 2. And there's your ping.
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests