I'm confused about a couple of things.
1.
You should always try to avoid such code.
What specifically do I need to avoid? Creating a sub for each button click?
2.
Sub Button_Click
Dim b AsButton = Sender
Dim number As Int = b.Tag
AStreams.Write(...)End Sub
I should have mentioned that a string is sent as well. Here's exactly what I need to do as shown with the code I'm using now:
Sub button1_click
SOCKET1.Initialize("client")
SOCKET1.Connect(ip, port, 500)
Dim buffer() As Byte
sNewLine = ("..1$$%*13") & CRLF
buffer = sNewLine.GetBytes("UTF8")
AStreams.Write(buffer)
End sub
Also, with regards to prefix mode, the information sent from the app to the server doesn't matter but the server isn't B4X. It's a microcontroller. If I understand you correctly, I don't need to do anything special when I send the data from the app but when I send data from the microcontroller to the app, I would only need to add a number in the beginning of the packet, which specifies the amount of bytes in the packet. Is that correct? Is this the correct way to initialize in prefix mode:
AStreams.Initializeprefix(SOCKET1.InputStream,false,SOCKET1.OutputStream, "astreams")
It won't work in prefix mode but will in normal mode. At the start of my packet, which is being sent from the server to B4i, I'm sending a 4 byte array of 0017 (sending more than 17 bytes but wanted to shorten it to see if it would work). Is that the correct thing to do?