You don't need to initialize filestream object each time you read the data.
Instead you should initialize once after creating the connection.
Maybe something like this will solve your problem:
Instead of:
Code:
Sub Timer2_Tick
ErrorLabel(connectionbreak)
If ComboBox2.SelectedIndex = 1 Then
If client.DataAvailable=true Then
Image4.LoadPicture("IconDaten1.bmp")
'REMOVE THIS LINE:filestream.New1(client.GetStream,false)
GPS_Server.GPSStream(filestream.ReadString)
Else
Image4.LoadPicture("IconDaten2.bmp")
End If
End If
Return
connectionbreak:
..
client.close
End Sub
Discard the data if ComboBox2.SelectedIndex doesn't equal 1:
Code:
Sub Timer2_Tick
ErrorLabel(connectionbreak)
If ComboBox2.SelectedIndex = 1 Then
If client.DataAvailable=true Then
Image4.LoadPicture("IconDaten1.bmp")
GPS_Server.GPSStream(filestream.ReadString)
Else
Image4.LoadPicture("IconDaten2.bmp")
End If
Else If client.DataAvailable Then
fileStream.ReadString
End If
Return
connectionbreak:
..
client.close
End Sub