AutoLan + IPv6

Thanks!  I’ve updated the ‘pong demo’ on the git.

I found an error with this code.

If you set forceIPV4 = false then the following line returns nil in the peerIP variable

peerIP, peerPort = s:getsockname(), 54613 <<-- this line always returns peerIP == nil.

I am running on the corona simulator and it crashes the simulator. I have a nice new Router (IPV4 and IPV6 support ) and new gaming laptop ( i7 ).

I turned this off because i could not get my phone and PC connect together and was trying to see if IPV4 was the cause.

As i am no socket / network dude then i have no clue on how to fix this correctly.

function server:startInternet() if(matchmakerTCPclient == nil) then server:start() --establish a TCP connection with the matchmaker server if(peerIP == nil) then local s = socketUDP() s:setpeername( "google.com", 54613 ) peerIP, peerPort = s:getsockname(), 54613 end matchmakerTCPclient = socketTCP() matchmakerTCPclient:settimeout(0) --this is the only blocking operation matchmakerTCPclient:connect(peerIP, peerPort) --bind on any availible port and localserver ip address. timers.connectMatchmaker = timer.performWithDelay(500, server.startInternet,-1) end

Thanks

Larry

anyone?

I will take a look at this when I can get to my laptop.

Can you if check my version works? Just curious

pong demo 3.zip

To check to see if you have ipv6

http://ipv6-test.com/

Current Progress

I figured out what lines of code Scott changed (pretty sure here) and modified them.

Note: This code is actually functional across both sockets 2 and 3 so that is very nice.

Next

Now I have to figure out how to recode the IPv4 ‘Broadcast’ code as ‘Multicast’ code (hopefully compliant w/ both IPv6 and IPv4.

Implications of the Changes to Address Types in IPv6

Broadcast addressing as a distinct addressing method is gone in IPv6. Broadcast functionality is implemented using multicast addressing to groups of devices. A multicast group to which all nodes belong can be used for broadcasting in a network, for example.

from:

http://www.tcpipguide.com/free/t_IPv6AddressingOverviewAddressingModelandAddressTyp-2.htm

Again, anyone with clues… I need em.

Thanks again,

Ed

PS - I’ll post all my changes when I’m done.

Ed,

As you’ve seen, the LuaSockets library was updated to version 3 which adds IPv6 support.  The one breaking change it has is that you can’t call setoption() on a TCP or UDP socket that was created by a socket.tcp() or socket.udp() call until **AFTER** you open the socket connection via a call to connect(), bind(), sendto(), setpeername(), or sockname().  This is because LuaSockets does not make the determination on whether to connect via IPv4 or IPv6 until after those connection calls.

Also note that LuaSockets adds the following new APIs:

  • socket.udp4()  – Creates an IPv4 only UDP socket
  • socket.udp6()  – Creates an IPv6 only UDP socket
  • socket.tcp4()  – Creates an IPv4 only TCP socket
  • socket.tcp6()  – Creates an IPv6 only TCP socket

The above will immediately create a valid socket where you **CAN** call setoption() on them immediately afterwards.  And if you want LuaSockets old version 2 behavior, then you should call socket.udp4() and socket.tcp4() instead, but just note that Apple will rejects apps that do this on iOS.

Here is a link to the updated LuaSocket version 3 API documentation…

   https://rawgit.com/diegonehab/luasocket/master/doc/reference.html

And you can also see another LuaSocket v3 UDP discussion I’ve had with an Enterprise developer in the link below, if you think it’ll help you any.

   https://forums.coronalabs.com/topic/63755-issues-with-socket-library-after-updating-corona-enterprise/?p=330816

I hope this helps!

@Joshua,

Thanks for the response.  I’ve read it once and will re-read it again later when my brain is ‘fresher’.  

Meanwhile, if you and others wonder why this came up…

I have a private tool I simply call ‘Reflector’.  This tool allows me to send any Runtime event from one device to another.  I use this to:

  • Send Apple TV remote inputs to the simulator (no need to install, fix, re-isntall, … just fix, reload simulator, wait for attach, test changes)
  • Send Phone/Tablet device inputs to simulator.  Same deal.
  • Same as above with the addition of requesting specific input types such as:
    • Virtual Joystick
    • One Touch
    • Two Touch
    • Joystick on left and touch on right

This video shows the latter in action:

https://www.youtube.com/watch?v=CAmNnomqPWQ

As you can see, I’m actually running two copies of the simulator, but that is to make this video.  The major elements in this video are:

  • Simulator on upper-left --> work in progress app on the simulator.

  • Simulator on upper-right --> This would normally be running on a device.  Write the app once, install once, run and it auto-configures on each reload of app in progress.

  • Code window at bottom - So you can see, it takes one line of code to request specific input events and optionally a input setup.

    – Asks ‘reflector’ device to send custom ‘onJoystick’ and ‘onOneTouch’ events – also asks it to build a special input with joystick on left and touch ‘pad’ on right receiver.init( { “onJoystick”, “onOneTouch”, “easyInput_oneStickOneTouch” } ) – asks for standard events: “key”, “axis”, “accelerometer”, – plus custom event ‘onDied’ receiver.init( { “key”, “axis”, “accelerometer”, “onDied” } )

Scott here let me take a look

Edit: here is link

https://www.dropbox.com/s/4nni4s085ofhg3y/pong%20demo.zip?dl=0

I am a bit slow having some device problem (water proof case did not work as aspected). I have been using the plugin above for about a year and have not run to any problems but of course have published it to apple.

In case that link does not still work I have it attached

Scott,

I downloaded your Pong Demo project.  As a quick solution, I got it working by replacing all calls to…

   socket.udp()

…with…

   socket.udp4()

After doing that, the game could be played in multiplayer.  And for your info, I tested it on Windows by running 2 Corona Simulator instances.

So, the next step would be to add support for IPv6 networks.

Ok I will take a look, it work on device without changes, but I will make the updates Joshua suggested.

Thanks,

Scott

Ok done

https://www.dropbox.com/s/scov9chhm917pxu/pong%20demo%20ipv6.zip?dl=0

Edit : I wast trying to update the forum post to add this link but it say it has been archived

Edit2: Let me know of any problems just got it works

One more thing. I’ve noticed that the “Client.lua” and “Server.lua” files both call socket.tcp() as well.
​If we’re going to hardcode it to IPv4 for the moment, then that should be changed to socket.tcp4() as well.

I’m not sure why that didn’t cause a problem for me though. But admittedly, I didn’t take a hard look at the code.  I just did a simple find/replace in the code and tested it out.

Wait should it be socket.tcp6 for IPv6

Calling socket.tcp6() would force that socket to communicate via IPv6 only, which is probably NOT what you want.  Especially since most home users don’t have an IPv6 LAN set up.

As a quick fix, changing all calls to socket.udp() to socket.udp4() and socket.tcp() to socket.tcp4() will restore the old LuaSocket behavior.

Ok I was just thinking of the apple requirements for ipv6 but that does not apply to ipv4 lan (right?). Sorry, I have not read all apple’s new requirements

https://www.dropbox.com/s/b2jcjvferki57fg/pong%20demo%202.zip?dl=0

Apple wants apps to support both IPv6 and IPv4 networks.

For client connections, they expect your app to favor IPv6 if available, but it’s not, then it should fallback to IPv4.

The code changes I’ve suggested up above would be rejected by Apple because it forces AutoLAN to support IPv4 only networks, which is how it used to work before.  I was just trying to help you guys in getting it working again.  The next step would be to *add* both IPv6 and IPv4 support to the AutoLAN library.  I’m pretty sure code changes are required to do so.

Ok made some changes.

https://www.dropbox.com/s/b2jcjvferki57fg/pong%20demo%203.zip?dl=0

Wow!  My Wife and I won second place at the golf tournament and you guys worked like fiends on this!

I think this means whenever I get stuck in the future I should ask a question and then go golfing! :slight_smile:

Really though, thanks to you each for work on this while I was absent.   I’m going to work my way though the discussion and try the linked zip(s).

Thanks again.

Fore!

PS - For context, Scott sent me an email yesterday as I was walking out the door for a tournament and I apologized for having to me gone.  So, while he knows what I’m talking about… I thought I ought to explain.