B4R Question Recive Long Data TCP

palang

Member
Licensed User
Hi
I'm having trouble getting big data
The data comes in a few pieces, but I want them all together
please help

TCP


Private Sub AStream_Client_NewData (Buffer() As Byte)
Log(Buffer)


'MyData Long '"0633064406270645064506450645064506450645064506450645064506450645064506450645064506450645064506450645064506450645064506450645064506450645064506450645064506450'64506450645064506450645064506450645064506450645064506450645064506450645064506450645064506450645064506450645064506450645064506450645064506450645064506450645064''50645064506450645064506450645064506450644506450645064506450645064450645064506450645064506445064506450645064506450644506450645064506450645064450645064506450645''06450644506450645064506450645064450645064506450645064506450645064506450645064506450645064506450645064506450645064506450645064506450645064506450645064506450645''0645064506450645064506450645064506450645064506450645064506450645064506450645")

GSM.astream.Write("AT+CMGS=""").Write("099010100121").Write("""").Write(Array As Byte(13))
'GSM.SEndData(JoinStrings(Array As String("AT+CMGS=","""",mobile,"""")).GetBytes)
Delay(1500)
GSM.astream.Write(Buffer).Write(Array As Byte(0x1a))

End Sub

Private Sub AStream_Client_Error

End Sub

Private Sub ClientConnect()
socket.Close
Dim st As Stream = Null
Dim port As UInt = 1919

If socket.ConnectIP(Array As Byte(192,168,43,143),port) Then
st = socket.Stream
End If

If st = Null Then
Log(" failed connect.")
Return
End If

Astream2.Initialize(st, "Astream_Client_NewData", "Astream_Client_Error")
'Astream2.MaxBufferSize=?



End Sub
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
This code is taken from HttpJob module:
B4X:
Private Sub AStream_NewData (Buffer() As Byte)
    If responseIndex + Buffer.Length > responseCache.Length Then
        Log("ResponseCache is full (", Buffer.Length, ")")
        Return
    End If
    bc.ArrayCopy2(Buffer, 0, responseCache, responseIndex, Buffer.Length) 'ByteConverter
    responseIndex = responseIndex + Buffer.Length
End Sub
It copies the response to a buffer.
 
Upvote 0

Similar Threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…