Options for peer 2 peer connection between two phones?

Hello!

I’m looking into developing a multiplayer app that can be played together on multiple (IOS and Android mixed) phones without the use of internet, a cloud service or an external wifi hotspot.

Before being able to send/receive anything over Lua sockets I would first need to establish a peer 2 peer connection between the devices, somehow. But does a standard even exist?

I’ve read articles on the internet claming IOS and Android can’t connect over Bluetooth. Is this true?

Likewise, Wifi Direct seems out as it’s not supported by IOS?

What about Wifi Tethering? I’ve come accross this app (Fast File Transfer) that turns your Android phone into a wifi hotspot allowing to connect your iPhone and transfer data. This sounds like a possible solution, but can it be done with Corona? Could the same app work on IOS and turn an iPhone into a Wifi hotspot too? Can I find code samples somewhere?

I’m quite surprised that, while all the hardware is present, there is still no standard way to have peer 2 peer connection between different devices?

Search for something called AutoLAN.  This is a WiFi Peer-to-Peer library by M.Y.Developers. They are not developing it any more, but it still works.

Rob

Thanks for the reply

I’ve looked at AutoLAN before, but isn’t it just a software library to communicate over sockets with UDP? As far as I understand, first I need a lower level hardware connection of some sort, whether by WIFI or internet or bluetooth, before I can even begin to communicate with sockets in libraries like AutoLAN. It’s this direct peer 2 peer ‘hardware’ connection I’m confused about.

I believe that the OS hardware and underlying TCP/IP stack will take care of everything for you and that AutoLAN sets up a listener on a port and your other apps just connect to that port.  I’ve never used it. I’m just echoing people in the forums who’ve used it successfully.

Rob

I’ve tried AutoLan before. Not sure if it still runs with the more recent Corona SDK builds but it sounds like it will do what you need. Both devices need to be on the same IP network segment or within the same routable network. The library has a lobby feature where you go and wait for connections. In this state your presence is “broadcasted” and the next person to go to the lobby see you there and you see their arrival. At that time you establish a direct peer to peer connection and play your game etc. There was a neat pong clone supplied with the library if memory serves me right. Take a look. 

exactly that, AutoLAN works fine when two phones are connected to the same shared local Wifi network or the internet, my question is how can I create a routable network without having an external wifi network/hotspot?

As far as I know I haven’t come across any apps that allow transferring data ‘directly’ between Android and IOS devices. It’s either sent over a local network or the internet, or done through wifi tethering. Between two Android phones you could have bluetooth or Wifi Direct, but things are different on the IOS end with Airdrop.

The lowest level networking you’re going to get out of Corona SDK is at the network socket layer.  You can open TCP or UDP sockets, bind to them and transmit/receive data.  Anything beyond that you will have to use Enterprise to get to the native level.

Rob

Hey Rob, I think AutoLan isn’t working anymore

AutoLan works just fine last I tried a few weeks ago. To run the multiplayer pong demo you do need to run it in v1 compatibility mode, but that’s just because of some old screen reference methods being used. The library itself is fine (but imo a bit overrated, its just offers a bit of common functionality written on top of the standard Lua socket library)

Have you tried running it on a device? It works fine in the simulator but not on the device. Seems to be socket.udp sendto isn’t sending data as it should, I’m running a network sniffer and I see the data being sent fine when code is running on the simulator but on the device I am getting nothing. sendto was returning a refused error at one point.

The pong demo worked on my Android tablet. If using Android, did you remember to add the necessary wifi/network permissions to the build settings?

My app has been working for the last year+ and just isn’t anymore. Using a network sniffer I am not seeing any UDP packets. I have even removed AutoLan and am just using lua socket and still not seeing any traffic from my UDP connection.

Search for something called AutoLAN.  This is a WiFi Peer-to-Peer library by M.Y.Developers. They are not developing it any more, but it still works.

Rob

Thanks for the reply

I’ve looked at AutoLAN before, but isn’t it just a software library to communicate over sockets with UDP? As far as I understand, first I need a lower level hardware connection of some sort, whether by WIFI or internet or bluetooth, before I can even begin to communicate with sockets in libraries like AutoLAN. It’s this direct peer 2 peer ‘hardware’ connection I’m confused about.

I believe that the OS hardware and underlying TCP/IP stack will take care of everything for you and that AutoLAN sets up a listener on a port and your other apps just connect to that port.  I’ve never used it. I’m just echoing people in the forums who’ve used it successfully.

Rob

I’ve tried AutoLan before. Not sure if it still runs with the more recent Corona SDK builds but it sounds like it will do what you need. Both devices need to be on the same IP network segment or within the same routable network. The library has a lobby feature where you go and wait for connections. In this state your presence is “broadcasted” and the next person to go to the lobby see you there and you see their arrival. At that time you establish a direct peer to peer connection and play your game etc. There was a neat pong clone supplied with the library if memory serves me right. Take a look. 

exactly that, AutoLAN works fine when two phones are connected to the same shared local Wifi network or the internet, my question is how can I create a routable network without having an external wifi network/hotspot?

As far as I know I haven’t come across any apps that allow transferring data ‘directly’ between Android and IOS devices. It’s either sent over a local network or the internet, or done through wifi tethering. Between two Android phones you could have bluetooth or Wifi Direct, but things are different on the IOS end with Airdrop.

The lowest level networking you’re going to get out of Corona SDK is at the network socket layer.  You can open TCP or UDP sockets, bind to them and transmit/receive data.  Anything beyond that you will have to use Enterprise to get to the native level.

Rob

Hey Rob, I think AutoLan isn’t working anymore

AutoLan works just fine last I tried a few weeks ago. To run the multiplayer pong demo you do need to run it in v1 compatibility mode, but that’s just because of some old screen reference methods being used. The library itself is fine (but imo a bit overrated, its just offers a bit of common functionality written on top of the standard Lua socket library)