[Help] UDP network

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
User avatar
g-ho4
Prole
Posts: 8
Joined: Sat Jul 21, 2012 4:43 pm

[Help] UDP network

Post by g-ho4 »

Hi guys!

I 've learned a lot of things on luasockets with the online documentation and the tutorial on the wiki (https://love2d.org/wiki/Tutorial:Networking_with_UDP) so i wanted to try my first "multiplayer" game!
I made a very simple Pong game engine a few weeks ago so i turned it into a multiplayer game :neko:
I can easily lauch the server script and 2 löve clients on my computer! However it is not the best to test a network game...

So my question is : how can i connect a client from another computer(on my local network...or maybe farther :ultraglee: ) to the server running on my computer ? (if it's possible)
For the moment I have on the client side :

Code: Select all

udp:setpeername("localhost",6112)

and on the server side :

Code: Select all

udp:setsockname("*",6112)
N.B:port 6112 is opened for me..

I think those lines are the keys, but i have no idea what to put as parameters (i've made many unsuccessful attempts on a client script i launched on another computer in my house)


I'm totally newb at this and didn't find any answer on the internet, and sorry for my english :emo:
User avatar
flashkot
Prole
Posts: 27
Joined: Sun Jul 29, 2012 4:56 pm
Location: ru

Re: [Help] UDP network

Post by flashkot »

Get IP addres of your server machine. If you on windows, open cmd prompt and type

Code: Select all

ipconfig
You will see IP address somewhere in the output.

Then put this into setpeername parameters instead of localhost.

That should be enough.
User avatar
g-ho4
Prole
Posts: 8
Joined: Sat Jul 21, 2012 4:43 pm

Re: [Help] UDP network

Post by g-ho4 »

Thanks for the answer!

But even with :

Code: Select all

udp:setpeername("192.168.0.12",6112)
for the löve client

I can't connect to the server running on my other computer, i deactivated all firewalls and opened port 6112 :(
User avatar
g-ho4
Prole
Posts: 8
Joined: Sat Jul 21, 2012 4:43 pm

Re: [Help] UDP network

Post by g-ho4 »

Hey!
Different experiences with udp and tcp scripts led me to think that:

=>TCP protocol works perfectly!
=>UDP protocol only works if the client's script is executed on the server machine (so if the client is connected with "localhost" param). The problem is that when the client's script is launched on another machine the "send" function (http://w3.impa.br/~diego/software/luaso ... .html#send) fails, never reaches the server but gives that strange error message :

Code: Select all

6
Any idea? :/
User avatar
flashkot
Prole
Posts: 27
Joined: Sun Jul 29, 2012 4:56 pm
Location: ru

Re: [Help] UDP network

Post by flashkot »

Sorry, can't help you at the moment. But, can you try to run unmodified example from the Wiki UDP tutorial?
User avatar
g-ho4
Prole
Posts: 8
Joined: Sat Jul 21, 2012 4:43 pm

Re: [Help] UDP network

Post by g-ho4 »

Hi!

Even the unmodified example from the udp tutorial doesn't work on two different machines :( I also unsuccessfully tried udp examples from that sources (https://github.com/sam-github/luasocket) on two machines...

It's strange that projects using tcp works perfectly (such as the Wiki Based RPG by Germanunkol viewtopic.php?f=5&t=10234)...
User avatar
flashkot
Prole
Posts: 27
Joined: Sun Jul 29, 2012 4:56 pm
Location: ru

Re: [Help] UDP network

Post by flashkot »

Strange. Looks like problem is with your network and not with Love2d or Lua.

I will test it today and write about my results.
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: [Help] UDP network

Post by Nixola »

Did you try testing through a fake lan, like Hamachi or Tunngle?
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
g-ho4
Prole
Posts: 8
Joined: Sat Jul 21, 2012 4:43 pm

Re: [Help] UDP network

Post by g-ho4 »

Yes, i think the problem comes from my own network... Any idea on "what can disturb an UDP connection ?" :emo:

Thanks Nixola, I'll try something with hamachi as soon as i can!
Post Reply

Who is online

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