Page 1 of 1

[Help] UDP network

Posted: Tue Aug 14, 2012 3:50 pm
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:

Re: [Help] UDP network

Posted: Tue Aug 14, 2012 4:01 pm
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.

Re: [Help] UDP network

Posted: Tue Aug 14, 2012 4:32 pm
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 :(

Re: [Help] UDP network

Posted: Tue Aug 14, 2012 7:38 pm
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? :/

Re: [Help] UDP network

Posted: Tue Aug 14, 2012 7:44 pm
by flashkot
Sorry, can't help you at the moment. But, can you try to run unmodified example from the Wiki UDP tutorial?

Re: [Help] UDP network

Posted: Wed Aug 15, 2012 8:25 am
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)...

Re: [Help] UDP network

Posted: Wed Aug 15, 2012 9:41 am
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.

Re: [Help] UDP network

Posted: Wed Aug 15, 2012 3:27 pm
by Nixola
Did you try testing through a fake lan, like Hamachi or Tunngle?

Re: [Help] UDP network

Posted: Thu Aug 16, 2012 8:08 am
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!