Hello, I have the following code in vb.net
It works perfectly
I need to move to b4a, tried this but it does not work
How to represent the? CChar(vbNullChar)
The logic is to send the lenght size of the bytes, then "CChar(vbNullChar)" and send the all bytes in an array.
How to do this with b4a?
B4X:
Public Shared Sub Send(ByVal msg As String)
Try
Using MS As New MemoryStream
Dim B As Byte() =StringToBytes(msg)
Dim L As Byte() = SB(B.Length & CChar(vbNullChar))
MS.Write(L, 0, L.Length)
MS.Write(B, 0, B.Length)
S.Poll(-1, SelectMode.SelectWrite)
S.Send(MS.ToArray, 0, MS.Length, SocketFlags.None)
End Using
Catch ex As Exception
isDisconnected()
End Try
End Sub
I need to move to b4a, tried this but it does not work
B4X:
Dim sb As StringBuilder
Dim cmd_String As String
Dim buffer() As Byte
sb.Initialize
sb.append(Asc("4")) .append(Asc("abcd"))
cmd_String = sb.ToString
buffer=cmd_String.GetBytes("UTF8")
astream.Write2(buffer, 0, buffer.Length)
How to represent the? CChar(vbNullChar)
The logic is to send the lenght size of the bytes, then "CChar(vbNullChar)" and send the all bytes in an array.
How to do this with b4a?