BASIC

Author Topic: TCP on iPhone device seems strange  (Read 6838 times)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10713
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: TCP on iPhone device seems strange
« Reply #15 on: 2011-May-12 »
Code: GLBasic [Select]
LOCAL socket% = -1 // I assume
sinit = SOCK_INIT() // First time run of the program - initialize the socket engine - DON'T DO THAT SOMEWHERE IN BETWEEN - don't make life complicated


... main program ...

IF NOT sinit THEN END // that can't happen. Really - it's always working

// connect to the server thing
socket = SOCK_TCPCONNECT(ip_address$, ip_port, timeout)
IF socket = -1 // Can't connect? Why?
        PLAYSOUND (on_error, 0, 0.9)
        connected = FALSE
        power = FALSE
        msg$ = "Failed to connect" + NETGETLASTERROR$(); px = 138 ; py = 152 // Tell us why!
        sinit = 0
        SOCK_SHUTDOWN
ELSE
    SOCK_SET_BLOCKING socket%, TRUE // set to blocking mode -> wait for each command to return (might help)
    IF SOCK_TCPSEND(socket%, "Yo mama, sockets like rockets") < 0; msg$=NETGETLASTERROR$(); RETURN FALSE; ENDIF
        PLAYSOUND (on_connect, 0, 0.9)
        connected = TRUE
        power = TRUE
        msg$ = "Successful connection" ; px = 112 ; py = 152
ENDIF
 
« Last Edit: 2011-May-12 by Kitty Hello »

Offline spicypixel

  • Prof. Inline
  • *****
  • Posts: 646
  • Pixel Artist
    • View Profile
    • SpicyPixel.net
Re: TCP on iPhone device seems strange
« Reply #16 on: 2011-May-12 »
Yo mama, sockets like rockets PMSL =) Thank you Gernot will adapt my code accordingly

SOCK_SET_BLOCKING is not in my manual here, hmmmm update methinks!
« Last Edit: 2011-May-12 by spicypixel »
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

Offline spicypixel

  • Prof. Inline
  • *****
  • Posts: 646
  • Pixel Artist
    • View Profile
    • SpicyPixel.net
Re: TCP on iPhone device seems strange
« Reply #17 on: 2011-May-12 »
SOCK_SETBLOCKING doesn't exist Gernot????? :O
http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10713
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Re: TCP on iPhone device seems strange
« Reply #18 on: 2011-May-13 »
get the beta version (android thread) and unzip the hotfix for it afterwards.
The manual is the online help that should show it.

Offline spicypixel

  • Prof. Inline
  • *****
  • Posts: 646
  • Pixel Artist
    • View Profile
    • SpicyPixel.net
Re: TCP on iPhone device seems strange
« Reply #19 on: 2011-May-14 »
I have now tried my app on an iPad and it works flawlessly with both 3G and WiFi connecting when it should and failing when it should. I can only presume on my JB'd iPhone that it has some internal firewall or proxy that re-routes the connections thus allowing the connection to be accepted internally and consequently my app saying "connected" but then obviously re-routing the connection nowhere because it can't unless of course I enter the correct IP and Port in which case the connnected message is indeed correct.

Like I have always said my app works on my JB'd phone too and connects flawlessy if the correct IP:Port is given and performs the commands successfully to the server my only problem was that it say "connected" pretty much regardless of IP:Port (apart from things like 255.255.255.255:port etc..)

I did send a message Gernot to see if you wouldn't mind trying the app of mine on your device to see if it is a JB issue with certain JB'd phones (mine is a white US iPhone 3GS) but I guess you are busy no problem mate and thank you for the help already. =)

http://www.spicypixel.net | http://www.facebook.com/SpicyPixel.NET

Comps Owned - ZX.81, ZX.48K, ZX.128K+2, Vic20, C64, Atari-ST, A500.600.1200, PC, Apple Mini-Mac.