Sub tmrWaitForData_Tick 'Checks the DataAvailable property. If data is available then it reads it.
'The server sends the data to all other clients.
If blnServer = False Then 'client
If Client.DataAvailable = True Then
s = stream.ReadString 'Reads the string from the stream.
txtReceive.Text = txtReceive.Text & CRLF & s
txtReceive.SelectionStart = StrLength(txtReceive.Text)-1
txtReceive.ScrollToCaret
If blnSound = True Then Sound("notify.wav")
End If
Else 'server
i = 0
Do While i < alClients.Count 'The server checks the data of all clients.
t = alClients.Item(i)
If Control("client" & t,Client).DataAvailable = True Then
s = Control("stream" & t,Binaryfile).ReadString
txtReceive.Text = txtReceive.Text & CRLF & s
txtReceive.SelectionStart = StrLength(txtReceive.Text)-1
txtReceive.ScrollToCaret
SendToAllClients(s,t) 'The server sends the data to all clients except of the client who sent the data.
If blnSound = True Then Sound("notify.wav")
End If
i = i + 1
Loop
End If
End Sub