Android Question aSyncStream not flushing data.

synasir

Member
Licensed User
Longtime User
Hi all,

I am using a fast timer to send sensor telemetry data back to my VB6 server using aSyncStreamtext. However, the data sometimes will all merge (not always).

TimerSvc1.Initialize ("TimerSvc1",50)

Dim mymessage As String
DateTime.DateFormat = "dd/MMM/yyyy HH:mm:ss"
dt = DateTime.Date(DateTime.now)
mymessage = "$$" & "@" & Round2(SensorData,2) & "@" & dt & "!#" & CRLF


If Socket1.Connected = True Then

TCPFlusso.Write (mymessage)

End if

Several mymessage will be sent together.



I tried the https://www.b4x.com/android/forum/threads/asyncstream-and-flush.146655/ to flush the buffer and force send a single mymessage but it does not seem to work (same behaviour as the code above).


Dim mymessage As String
DateTime.DateFormat = "dd/MMM/yyyy HH:mm:ss"
dt = DateTime.Date(DateTime.now)
mymessage = "$$" & "@" & Round2(SensorData,2) & "@" & & dt & "!#" & CRLF


If Socket1.Connected = True Then


r.Target=TCPFlusso
r.Target=r.GetField("aout")
aout=r.GetField("out")
TCPFlusso.Write2 (mymessage.GetBytes("UTF8"),0,mymessage.Length)
aout.RunMethod("flush",Null) ' force send

End if

I am using just regular Winsock in my VB6 server to receive the data.


Any ideas on how to solve this problem?

Thanks.
 

drgottjr

Expert
Licensed User
Longtime User
agreed. i was just trying to get the point across that in java's implementation of outputstream, flush() doesn't do what it sounds like it's supposed to do. whether buffers are flushed or not - at least in the case of outputstream - it's not happening as a result of flush().
if the server is blocking, i don't see why the android client couldn't block in a service on a separate thread. async in a time-critical environment seems to be inviting disappointment. if op implemented his own winsock code, he should be able to get something going with java sockets. not as easy as using a ready-made library, but it seems that the library is not doing what he needs. async suits android from google's point of view regarding ui.
 
Upvote 0

bocker77

Active Member
Licensed User
Longtime User
Why not implement message queueing (MQTT) and let that handle your messages? If it is anything like IBM's Websphere MQ which I believe it is then your messages are quaranteed to arrive!
 
Upvote 0

techknight

Well-Known Member
Licensed User
Longtime User
Why not implement message queueing (MQTT) and let that handle your messages? If it is anything like IBM's Websphere MQ which I believe it is then your messages are quaranteed to arrive!

afaik, an MQTT client was never written for VB6. would have to start from scratch or use a DLL.
 
Upvote 0

bocker77

Active Member
Licensed User
Longtime User
But VB6 apparently does supprt message queueing. At least doing a precursory google search looks as if it does. Message queueing on all platforms shouldn't matter what flavor is running on a specific OS if they implemented the architecture.
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
Me personally, if your old VB6 code is not too large or complicated with a UI, I would personally redevelop your VB6 application as an MQTT broker either with B4R (ESP8266 or an ESP32) or with B4J as a background worker.

I'm not sure if the link below will help you with your current issue.


Enjoy...
 
Upvote 0
Top