Sub Timer2_Tick
ErrorLabel(connectionbreak)
If ComboBox2.SelectedIndex = 1 Then
If client.DataAvailable Then
Do While eclient.DataAvailable
GPS_Server.GPSStream(filestream.ReadString)
Loop
Image4.LoadPicture("IconDaten1.bmp")
Else
Image4.LoadPicture("IconDaten2.bmp")
End If
Else
Do While client.DataAvailable
fileStream.ReadString
Loop
End If
Return
connectionbreak:
..
client.close
End Sub
This is my code, the same problem as my last posts. A simple code but it doesn' work:
Sub App_Start
Form1.show
client.New1
client.Connect("217.91.33.???,55355)
filestream.New1(client.getstream,false)
timer1.Enabled=true
End Sub
Sub timer1_Tick
if client.DataAvailable=true then
Label1.Text=filestream.readstring
else
Label1.Text="no data"
end if
End Sub
The server sends only string as NMEA (RMC and GGA) every two seconds. When i block the gate from the server, so that there is no data sending, the application blocks in this line: Label1.Text=filestream.readstring. Than, there is no chance to end the application or even push a button. I have tested it with different timer from client and server, but it always stops in filestream.readstring. When I open the gate, the application will continue without problems.
I have spoken with the author from the server-code. He says, that there is shure no data, when the gate is blocked. He says, that the filestream.readstring is a blocked function. It waits until there is any data. But i can't catch the mistake with client.dataavailable. Is it possible, that there is a different between reading the filestream until it is emty and read from a filetream, that is emty from the beginning? Because, if i read a full filestream until it is emty, then Label1.text shows "no data".
When I connect to a port, where is no data from the beginning, the application stops an locks up until I gi´ve data to the stream.
:sign0085::sign0085::sign0085:
I think, that i will fall into despair....
I have written a smal testapp to see, where the problem is.
When the server sends no data, the application will stop as long,
as the server sends data again. When there is data again, the Application
runs without any problems. Is there no data, i only can stop the app with the
task-manager or break down the GPRS-connection. Here the code:
Sub App_Start
Form1.Show
client.New1
Client.Connect ("87.139.??.???",11112)
filestream.New1(client.GetStream,false)
timer3.Enabled=true 'timer3=500 or 1000 ms'
End Sub
Sub Timer3_Tick
If client.DataAvailable=true Then
filestream.ReadString
label5.Text="data!"
Else
label5.Text="no data!"
End If
End Sub
The server-connection is always available!
but that was not the problem, which I mean.
I think, that client.dataavailable on this server (sends NMEA every two seconds as string in a TCP-protocol) also doesn't run.
When the server stop sending data, the application lock up in the line filestream.readstring.
Is there a way to write another sub with a counter etc.?
It does happen on his server, I've tried it - see post #31.From my point of view this can never happen, because the filestream.ReadString is only called if the client.DataAvailable condition is true.
So, my question is: does it really deadlock or just block for a couple of seconds...?
' globals
Count = 0 ' count of bytes received
Dim WebResp(4096) As Byte ' read buffer
Sub DataAvailable
ErrorLabel(DAerr)
count = Stream.ReadBytes(WebResp(),4096)
Return true
DAerr:
Return false ' if the Read times out it throws an exception
End Sub
Sub NetGetData(req)
msg ="An error occurred connecting to " & URL
ErrorLabel("err2")
Client.New1
Client.Connect(URL, Port)
Stream.New1(Client.GetStream,true)
StreamObj.Value = Client.GetStream 'StreamObj is a Door library Object
StreamObj.SetProperty("ReadTimeout",1) ' set the Read stream timeout to 1 mSec
msg = "GET /" & req & " HTTP/1.1" & Crlf
msg = msg & "Host: " & URL & Crlf
msg = msg & "Proxy-Connection: Keep-Alive" & Crlf
msg = msg & "Pragma: no-cache" & crlf
WebReq() = Stream.StringToBytes(msg)
Stream.WriteBytes2(WebReq(),0,StrLength(msg))
Timer = 0
Do
Sleep(SleepMs)
Timer = Timer + SleepMs
If Timer >= Timeout Then
Return "A timeout occurred communicating with " & Device
End If
Loop Until DataAvailable
msg = Stream.BytesToString (WebResp(), 0, Count)
Client.Close
Return msg
End Sub
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?