Android Question Write bytes to Network Problem

zapadepowday

New Member
Licensed User
Longtime User
B4X:
Sub Process_Globals

      Dim BS As Socket
      Dim out As OutputStream
      Dim Header As String = Chr(255) & Chr(254)& "Blista->" & Chr(255) & Chr (254)
      Dim Bconv As ByteConverter
    Dim Buffer(12) As Byte         
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
 
    BS.Initialize("Socket1")
    BS.Connect("192.168.1.95", 8889, 0)

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub Socket1_Connected (Successful As Boolean)
    If Successful = False Then
        Msgbox(LastException.Message, "Error connecting")
        Return   
    End If
    ToastMessageShow("Connected successfully", False)
  out.InitializeToBytesArray(12) 
    Buffer=Bconv.StringToBytes(Header,"ASCII")
    out.WriteBytes(Buffer,0,12)
    Log(Header)
  out.Flush
  BS.Close
End Sub

Can anyone please explain why this code does not actually send the bytes across the network.
I know I am missing something but have gone round in circles looking for it.
Any help appreciated.
 
Top