iOS Question Sample code for sending data from iOS device to server (UTF8)

Discussion in 'iOS Questions' started by dclarkchem, Jan 18, 2018.

  1. dclarkchem

    dclarkchem Member Licensed User

    Have successfully created an app with B4A, but wondering if there is sample code to do this with B4i. Here is part of what we've done with B4A:
    Sub Socket1_Connected(Connected As Boolean)As Boolean
    If Connected = True Then
    ToastMessageShow("Server not available",True)
    "Server not available"
            btnConnect.Text = 
    End If
        btnConnect.Enabled = 
    End Sub
    Sub AStreams_NewData (Buffer() As Byte)
    Dim msg As String
    Dim cMsg As String
    Dim unsignedi As Int
    Dim signedb As Byte
        msg = 
    BytesToString(Buffer, 0, Buffer.Length, "ASCII")
    For i = 0 To msg.Length -1
            signedb = Buffer(i)
            unsignedi = 
    Bit.AND(0xff, signedb)
            cMsg = cMsg & 
        lblMsg.Text = x & 
    " / " & msg.Length & " - " & msg
    End Sub
    Sub SendData(msg As String)
    Dim Buffer() As Byte
        Buffer = msg.GetBytes(
    Array As Byte(254))
    End Sub
    Would appreciate any help, before I spend 3 weeks and then figure out that it can't be done with B4i.[/code]
    Last edited: Jan 19, 2018
    spairo likes this.
  2. Erel

    Erel Administrator Staff Member Licensed User

  3. dclarkchem

    dclarkchem Member Licensed User

    Thanks for that link. After spending a couple of days trying to get the serializator to properly work with our project(s), we gave up in frustration. We were about to abandon all hope, but decided to take Erel at his word ("the code works for both B4A and B4i").

    We stripped down our working B4A program (part of it is shown above) to the bare essentials and verified that it still worked. We tried to write the B4i equivalent. There are definitely structural changes that had to be made, but we got it working this morning ! ! !

    OK, we're only half way to first base, but at least we're in the game again.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice