BASIC

Author Topic: Socket does not work on iOS (confirmed)  (Read 1392 times)

Offline msx

  • Prof. Inline
  • *****
  • Posts: 773
    • View Profile
My app uses sockets and works perfectly on Android and Windows, however it does not connect on iOs. A simple function like the following...

Code: GLBasic [Select]
FUNCTION CompruebaINET:
// Comprobamos conexión, 1=Si
LOCAL bInternet=0, sock%
        SOCK_INIT()
        sock% = SOCK_TCPCONNECT("www.google.com", 80)
        IF sock%>=0 THEN bInternet=TRUE // check return value. Is it 0 or -1 on error?
        SOCK_CLOSE(sock%)
        SOCK_SHUTDOWN
        RETURN bInternet
ENDFUNCTION

... always responds 0.

Could it be a BUG?.
« Last Edit: 2017-Mar-07 by spacefractal »

Offline msx

  • Prof. Inline
  • *****
  • Posts: 773
    • View Profile
Re: Socket does not work on iOS
« Reply #1 on: 2017-Jan-18 »
Could anyone confirm it ?. It's important to me.  :whistle:

Offline msx

  • Prof. Inline
  • *****
  • Posts: 773
    • View Profile
Re: Socket does not work on iOS
« Reply #2 on: 2017-Mar-06 »
I've done some tests I note that the SOCK_INIT () command works correctly and responds 1, which means that initiates the socket well. However, when the connection is made using SOCK_TCPCONNECT (), an error occurs and responds -1.

XCode displays this error just after using SOCK_TCPCONNECT ().

Code: GLBasic [Select]
2017-03-05 14:22:39.066829 GLB_PRODUCT_NAME[2984:533812] Warning: Libinfo call to mDNSResponder on main thread
 

And NETGETLASTERROR$() responds...

Code: GLBasic [Select]
2017-03-05 14:22:39.381579 GLB_PRODUCT_NAME[2984:533812]  - 57 Socket is not connected
 

I do not know what can happen.

I hope someone can help me with this data I provide.  :whistle:
« Last Edit: 2017-Mar-06 by msx »

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3305
    • View Profile
    • Space Fractal
Re: Socket does not work on iOS
« Reply #3 on: 2017-Mar-06 »
Give a full example. Here glbasic v12 is not supported.

On iOS IPv6 was recently required, which means glbasic v12 won't been supported using those commands.

I'm newer use those commands, so I'm do not know about all before testing l.

Also glbasic also calls them using main thread, which is very bad idea. It's a asyncron....
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline msx

  • Prof. Inline
  • *****
  • Posts: 773
    • View Profile
Re: Socket does not work on iOS
« Reply #4 on: 2017-Mar-06 »
The example is very simple, but I add it here.

Code: GLBasic [Select]
       
IMPORT "C" int glb_IOS_Log(const char*)
       
LOCAL ok%,sock%

ok% = SOCK_INIT()
       
sock% = SOCK_TCPCONNECT("www.google.com", 80, 5000)
glb_IOS_Log (sock%+" - "+NETGETLASTERROR$())

PRINT "TEST",0,0
SHOWSCREEN
MOUSEWAIT
END
 

sock%=-1
NETGETLASTERROR$()=57 Socket is not connected


I use the latest version of GLB and XCode iOS 10 Beta 3, but with beta 1 also did not work.

glb_IOS_Log prints a string in XCode via NSLog.
« Last Edit: 2017-Mar-06 by msx »

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3305
    • View Profile
    • Space Fractal
Re: Socket does not work on iOS
« Reply #5 on: 2017-Mar-06 »
Im or Gernot might not been able to fix the issues, due Apples requirements!

Also most of those commands also require redesign to use asynkron in own thread and might cause app to crash on slow networks.

But I'm will take a look anyway. But here iOS is quite strange in that area.
« Last Edit: 2017-Mar-06 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3305
    • View Profile
    • Space Fractal
Re: Socket does not work on iOS
« Reply #6 on: 2017-Mar-06 »
Edit. Here is the main issue me thinks:
https://techcrunch.com/2016/06/14/apple-will-require-https-connections-for-ios-apps-by-the-end-of-2016/

Howover apple delayed with no new date set recently (very few used it actually). so here is how you disable that (you should only do that on domains used):

http://stackoverflow.com/questions/30731785/how-do-i-load-an-http-url-with-app-transport-security-enabled-in-ios-9/30732693#30732693
« Last Edit: 2017-Mar-06 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline Marmor

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 908
  • 96A285CC
    • View Profile
    • my youtube channel
Re: Socket does not work on iOS
« Reply #7 on: 2017-Mar-06 »
if we cant solve this ill sell my iphone .
i dunno but  :puke:

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3305
    • View Profile
    • Space Fractal
Re: Socket does not work on iOS
« Reply #8 on: 2017-Mar-06 »
iOS is quite much more restrictive to prevent all those scam and hacker thing.

Im thinks all http connection attempts is now blocked by default, hence its won't connect. You must now set domains that is allowed http connections in your plist file as exceptions. You should not accept all domains, which the app might got rejected by Apple, if you don't have a good reason (browsers etc).

I'm donno https is supported by glbasic and here I'm have no clue how it's works at all.

But Here will not add those entries in the plist automatically, because far from all games and apps require it and might cause other issues.

Also all connections should been done in own thread and not in main thread. Glbasic does not do that and also can cause app to crash due waiting....


« Last Edit: 2017-Mar-06 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline msx

  • Prof. Inline
  • *****
  • Posts: 773
    • View Profile
Re: Socket does not work on iOS
« Reply #9 on: 2017-Mar-07 »
Unfortunately it does not work for me. I have tested all possible combinations in my plist file.

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3305
    • View Profile
    • Space Fractal
Re: Socket does not work on iOS
« Reply #10 on: 2017-Mar-07 »
does NETaddress supports 64bit pointers? its could also been that issue, if the returned adress is a pointer, then its will fails on iOS.

This can been mean since android and windows still supports 32bit apps, but some commands can still have 64bit issues, required by iOS. Those commands can been one of them.

Hence it's a beta.

Im take a look later this week, if its that reason. Im thinks it's is.
« Last Edit: 2017-Mar-07 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline msx

  • Prof. Inline
  • *****
  • Posts: 773
    • View Profile
Re: Socket does not work on iOS
« Reply #11 on: 2017-Mar-07 »
I think it may be a problem with 64bit adaptation, since my previous app worked correctly with socket.

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3305
    • View Profile
    • Space Fractal
Re: Socket does not work on iOS (confirmed)
« Reply #12 on: 2017-Mar-07 »
its not a 64bit bug, im confirm this happens with the security thing is disabled and that even im only ran in 32bit mode for giving its most compatible, even this is the none Apple way, then its was just a test..

Im get a socket error code 22 in the Netadress(), but im do got it detect its a iPv4 adress (since im cant test iPv6 adresses).

Here its still fails when its try connect.

So im confirm its a bug.

Im will also checking im uses your newest cpp files, but im updated it recently, and can see a lots of ipv6 stuff.

here is the "log" im got:

call netAdress()
this is a ipv4 adress (this is correct for me).

Connect Error 22 (im printf all strings there was in that command)..
[GLB]->-1 (back in glbasic)
[GLB]->57 Socket is not connected
« Last Edit: 2017-Mar-07 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.

Offline msx

  • Prof. Inline
  • *****
  • Posts: 773
    • View Profile
Re: Socket does not work on iOS (confirmed)
« Reply #13 on: 2017-Mar-07 »
It's definitely not a permissions problem.

Socket connection through Objective-c works perfectly.

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3305
    • View Profile
    • Space Fractal
Re: Socket does not work on iOS (confirmed)
« Reply #14 on: 2017-Mar-07 »
its more a url issue of some sort.

im need talk to Gernot first. Its a strange issue. Im still not 100% sure why its happens, but im are not expert in that area at all.

Gernot, can you send me the newest version of the source, so im can make sure im using the newest version?

Its even borks in 32bit test. so its not even a 64bit issue at all and/or permission.
« Last Edit: 2017-Mar-07 by spacefractal »
Greedy Mouse - Karma Miwa - Spot Race - CatchOut - Android Extras - is on a vacation trip, home before end of few days in jan.