Socket does not work on iOS (confirmed)

Previous topic - Next topic

msx

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?.

msx

Could anyone confirm it ?. It's important to me.  :whistle:

msx

#2
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:

spacefractal

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....
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

msx

#4
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.

spacefractal

#5
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.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

spacefractal

#6
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
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Marmor

if we cant solve this ill sell my iphone .
i dunno but  :puke:

spacefractal

#8
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....


Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

msx

Unfortunately it does not work for me. I have tested all possible combinations in my plist file.

spacefractal

#10
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.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

msx

I think it may be a problem with 64bit adaptation, since my previous app worked correctly with socket.

spacefractal

#12
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
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

msx

It's definitely not a permissions problem.

Socket connection through Objective-c works perfectly.

spacefractal

#14
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.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/