Hi all,
Anyone knows a LUA library to do UDP hole punching ?
Thanks!
Cheers,
UDP hole punching
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Roland_Yonaba
- Inner party member
- Posts: 1563
- Joined: Tue Jun 21, 2011 6:08 pm
- Location: Ouagadougou (Burkina Faso)
- Contact:
Re: UDP hole punching
Thanks for your reply, I found nothing in the mailing list archive and I'm too lazy to subscibe, I think I'll just go try to implement something myself.
Cheers,
Cheers,
Re: UDP hole punching
Hi guys,
Just for the record I managed to get something working following this paper:
http://www.brynosaurus.com/pub/net/p2pnat/
I've got a "lobby" server running with a simple LUA script returning to each clients public and private IPs of the server (and vice-versa for the server). And on the LOVE side I'm using Enet to try to establish the connection to both IPs, one important thing is to try to connect from the client AND from the server to be sure to "punch" the hole on both side, then I only use the first connection which succeed and discard the other one.
Cheers,
PS: BTW, Enet totally rocks, thanks for adding it to LOVE!
Just for the record I managed to get something working following this paper:
http://www.brynosaurus.com/pub/net/p2pnat/
I've got a "lobby" server running with a simple LUA script returning to each clients public and private IPs of the server (and vice-versa for the server). And on the LOVE side I'm using Enet to try to establish the connection to both IPs, one important thing is to try to connect from the client AND from the server to be sure to "punch" the hole on both side, then I only use the first connection which succeed and discard the other one.
Cheers,
PS: BTW, Enet totally rocks, thanks for adding it to LOVE!
Re: UDP hole punching
Hey @Fenrir
I'm facing the similar problem.
I want several clients to have a separate sqlite database, but keep all of the clients in sync. I use UDP for this and on the local network it works. But it would be better if I could sync from anywhere I have an internet connection. So, then I had the idea of having a remote server with open port 42000.
The remote server would basically work as a share station ("lobby") for UDP messages. Each client can send some message to the remote server and also at the same time listen for others messages and pick up the ones it needs.
But frankly that didn't work. It seems like the message is send, but I can not listen to the remote server. If I try to see what my :getsockname() is .. it's the local IP of my mashine instead of the remote servers ip, although I was bound to it.
Turn's out I maybe need to use some NAT hole punching technique to connect the wires... Would you share your code with me please?, so I get an idea what to do? I basically understand the concept, but don't know where to start. Do I need some script to run on the remote server S which connects Client A & Client B?
I'm facing the similar problem.
I want several clients to have a separate sqlite database, but keep all of the clients in sync. I use UDP for this and on the local network it works. But it would be better if I could sync from anywhere I have an internet connection. So, then I had the idea of having a remote server with open port 42000.
The remote server would basically work as a share station ("lobby") for UDP messages. Each client can send some message to the remote server and also at the same time listen for others messages and pick up the ones it needs.
But frankly that didn't work. It seems like the message is send, but I can not listen to the remote server. If I try to see what my :getsockname() is .. it's the local IP of my mashine instead of the remote servers ip, although I was bound to it.
Turn's out I maybe need to use some NAT hole punching technique to connect the wires... Would you share your code with me please?, so I get an idea what to do? I basically understand the concept, but don't know where to start. Do I need some script to run on the remote server S which connects Client A & Client B?
Blog herrsch.de
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: UDP hole punching
I'd consider telling you the same as what i tell anyone in this situation, but to be frank, this feels like one of the more reasonable reasons for necroing a 3 year old thread... we'll see.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: UDP hole punching
Sorry, I'm not sure if you're being sarcastic or friendly.. but why does the thread age matter? Why would I create a new thread for the same question anyway? It's a discussion and some questions and solutions still apply today. Maybe I get an answer from somebody else, even if the original author might be not active anymore.
Blog herrsch.de
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: UDP hole punching
A bit of both, to be honest.jack0088 wrote: ↑Sun Jul 02, 2017 5:39 pm Sorry, I'm not sure if you're being sarcastic or friendly.. but why does the thread age matter? Why would I create a new thread for the same question anyway? It's a discussion and some questions and solutions still apply today. Maybe I get an answer from somebody else, even if the original author might be not active anymore.
And it matters because, depending on circumstances like what the thread is about, people usually necropost in threads that have obsolete information in them, for one reason or another (e.g. it was relevant to an old löve version only); but as you stated, since the topic is still relevant now, it's still one of the times that it's actually not an issue, as i originally said.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: UDP hole punching
If your server has an open port, then you don't need hole punching at all! Just make sure to have the client initiate the connection.
What do you mean you cannot listen to it? With UDP you don't really "listen" to any specific host, you just get whatever is sent to you. (Though if you've called connect you should only receive packets from the host you connected to.)
Also, getsockname is behaving correctly, since it returns what you're listening on: the ip your computer uses to reach the internet (which is usually the local ip).
Re: UDP hole punching
Thats the thing. I opened ports on my remote server so anyone can access it.
I do not have clients or servers in that sense, since the app runs with same code on all devices. Every device can post udp messages and receive others messages. I just open socket and send information to remote server. Then immediatelly change the socket to receive something from that server.
Code: Select all
udp = socket.udp()
udp:settimeout(0)
udp:setsockname(self_ip, port) --force sending through specified port
udp:sendto(msg, remote_server_ip, port) --seems to work
udp:settimeout(.5)
udp:setsockname(remote_server_ip, port) --nothing received
udp:receivefrom()
udp:close()
Blog herrsch.de
Who is online
Users browsing this forum: No registered users and 3 guests