Sub AStream_NewData (buffer() As Byte)
Dim st As String
If rcvr Then
Select msgtype
Case 0
...
msgtype = 1
Case 1
...
msgtype = 2
Case 2
....
msgtype = 3
Case 3
Rcount = buffer.Length
rafrcv.WriteBytes(buffer, 0, Rcount, Rposition)
Rfilesize = Rfilesize - Rcount
Rposition = Rposition + Rcount
acumulator = acumulator + Rcount
bar.Progress = 100 * acumulator / totalsize
If Rfilesize <= 0 Then
rafrcv.Close
msgtype = 1
If acumulator >= totalsize Then bar.Visible = False
Sbuffer = bc.StringToBytes( "not busy" ,"UTF8")
AStream.Write(Sbuffer)
End If
End Select
Else
st = BytesToString(buffer, 0, buffer.Length, "UTF8")
If st = "not busy" Then busy = False
End If
End Sub