Sockets with iOS, Android, simulator

Hello,

I’m facing a strange problem… my program establishes a socket (UDP) comm with a server. It works quite nicely, except in Android + Wifi (Android + 3g, 4g works ok).

So it works in the simulator, with an iPad (wifi only, no 3G), and mobile data android, but not in (I tested a couple of different phones) android + wifi.

I’m using lua sockets, and have android.permission.INTERNET in my build.settings (and properly reflected in the phone app settings).

Any ideas? This is a problem I was not expecting at all…

Thanks,

jaime

Any error messages that can help trouble shoot this?

Rob

Hi Rob,

just tested that - socket:sendto(…) is returning nil, message “hostname nor servname provided, or not known”

Quite misleading, as both hostname and port are verified - and as said, same code works in the simulator and iOS…

Still trying to find out…

Thanks,

jaime

Ok, found something. It is related to biding (or failing to do so) the UDP socket.

I’ll work out the cases - maybe it is just more restricting in Android?

Best regards,

jaime

Ok, so the only way I’ve found it working in all 3 (iOS iPad, several Android, simulator) is using:

socket:setsockname( “specific IP”, “specific port” )

socket:sendto( “whatever”, “IP”, “port” )

Just “send” won’t work (not even after the setsockname)

And setsockname with “*” as the address field won’t work either (Android, works in iOS and simulator).

Seems a bit weird to me, but it works now so I’m happy.

Best regards,

jaime

Any error messages that can help trouble shoot this?

Rob

Hi Rob,

just tested that - socket:sendto(…) is returning nil, message “hostname nor servname provided, or not known”

Quite misleading, as both hostname and port are verified - and as said, same code works in the simulator and iOS…

Still trying to find out…

Thanks,

jaime

Ok, found something. It is related to biding (or failing to do so) the UDP socket.

I’ll work out the cases - maybe it is just more restricting in Android?

Best regards,

jaime

Ok, so the only way I’ve found it working in all 3 (iOS iPad, several Android, simulator) is using:

socket:setsockname( “specific IP”, “specific port” )

socket:sendto( “whatever”, “IP”, “port” )

Just “send” won’t work (not even after the setsockname)

And setsockname with “*” as the address field won’t work either (Android, works in iOS and simulator).

Seems a bit weird to me, but it works now so I’m happy.

Best regards,

jaime