Android Question b4a sockets and asyncstreams

igpf

Member
Licensed User
Hi Guys,

So i'm basically trying to make a connection to an "external" ip/server. The second, i connect I get a
"AStreams_Terminated"

B4X:
Sub Process_Globals
    Dim Socket1 As Socket
    Dim AStreams As AsyncStreams
 
End Sub
Sub Activity_Create(FirstTime As Boolean)
    Socket1.Initialize("Socket1")
    If Socket1.IsInitialized Then
        Socket1.Connect("111.111.111.111", "50000", 5000)
    End If
End Sub
Sub Socket1_Connected(Successful As Boolean)
         
    Try
        If Successful = True Then
            If Not(AStreams.IsInitialized ) Then
                AStreams.Initialize(Socket1.InputStream,Socket1.OutputStream,"AStreams")
                Sleep(1000)

            End If
            Log(" *** sockets::AStreams.Connected " & Successful)
        Else

        End If

    Catch
        Log(" *** sockets::AStreams_Connected " & LastException.Message )
     
    End Try

Sub AStreams_Terminated()
    Log("AStreams_Terminated")
  
    'should this be here???
    Socket1.Close
End Sub

Sub btnLogin_Click
    Dim sCMD as string
    sCMD = "ping"
    AStreams.Write(sCMD.GetBytes("UTF8"))
End Sub
the last line...
AStreams.Write(sCMD.GetBytes("UTF8"))
essentially fails, and i get the "AStreams_Terminated".....

any thoughts would be greatly appreciated.

i'm running the code in python, works perfect... android not so much...
 
Top