Page 1 of 1

Questions about Networking with UDP Tutorial

Posted: Sun Oct 09, 2016 4:33 pm
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.

Re: Questions about Networking with UDP Tutorial

Posted: Sun Oct 09, 2016 4:50 pm
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

Re: Questions about Networking with UDP Tutorial

Posted: Sun Oct 09, 2016 4:54 pm
by BruceTheGoose
Ahhhhh makes sense. Could I obtain this information via cmd?

Re: Questions about Networking with UDP Tutorial

Posted: Sun Oct 09, 2016 5:21 pm
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.

Re: Questions about Networking with UDP Tutorial

Posted: Sun Oct 09, 2016 5:55 pm
by BruceTheGoose
Last question, If i wanna display the client's ping speed. Is this possible via lua socket?

Re: Questions about Networking with UDP Tutorial

Posted: Sun Oct 09, 2016 7:29 pm
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.