hi, I am connecting to a tcp device via clientsocket and sending a message via AsyncStreams, if I create a sub to send the message can I receive the reply on the same sub or only through AStreams1_NewData?
In one cycle, I would need to send data and receive an answer immediately before continuing to send the next message.
when I call this sub I do not receive the answer and therefore I go on sending messages without verifying the result and I cannot in this way give the opportunity to try again to resend the message that was not successful
In one cycle, I would need to send data and receive an answer immediately before continuing to send the next message.
Sen Message:
Sub InviaComandoCustom (comando As String )
If clientSocket.Connected = True Then
Log("Inizio Invio comando")
'AStreams1.InitializePrefix(clientSocket.InputStream,False,clientSocket.OutputStream,"clientSocket")
Dim stringa As String = NumberFormat(Main.contatore,2,0) & "0" & comando
Dim ck As Int = CalcolaCK(stringa)
stringa = stringa & NumberFormat(ck,2,0)
If Main.contatore = 99 Then
Main.contatore = 0
End If
Dim b(stringa.Length + 2) As Byte
b(0) = 2
b(stringa.Length + 1) = 3
Dim BC As ByteConverter
Log("send : " & stringa)
BC.ArrayCopy(stringa.GetBytes("ASCII"),0,b,1,stringa.Length)
If clientSocket.IsInitialized = True And clientSocket.Connected = True Then
AStreams1.Write2(b,0,b.Length)
End If
Main.contatore=Main.contatore+1
Log("FINE INVIO COMANDO")
Else
Msgbox2Async("Nessuna Stampante connessa , riprovare il collegamento ? ","ERRORE","SI","NO","",Null,False)
Wait For Msgbox_Result (Result As String)
If Result = DialogResponse.POSITIVE Then
AvviaConnessione
End If
End If
End Sub
when I call this sub I do not receive the answer and therefore I go on sending messages without verifying the result and I cannot in this way give the opportunity to try again to resend the message that was not successful