asyncstream sendcomplete?

vangogh

Active Member
Licensed User
Longtime User
Dim tcpClient As Socket
Dim tcpFlusso As AsyncStreams
dim mymessage as string


tcpFlusso.Initialize(tcpClient.InputStream,tcpClient.OutputStream,"tcpFlusso")

mymessage="1234"

(connect and so on....)

tcpFlusso.Write(mymessage.GetBytes("UTF8"))


How can I know if the message has been sent?

when I send the message, I am not sure that the connection is OK, and is not a good idea to repeately send a ping-ping handshake...

thank you
 

vangogh

Active Member
Licensed User
Longtime User
If there is no error then the data should arrive. Use the Error event to find errors: http://www.b4x.com/forum/basic4android-getting-started-tutorials/7669-asyncstreams-tutorial.html

I must say that I'm using a scheduled ping to verify that the connection is still alive, and it is working very good.


I was using the "connected" property periodically and before sending anything

If you, Erel, my Master, use a periodical ping, I get afraid... :sign0148:


can I continue, oh Master, to simply test tcpClient.Connected test before sending any message or every x seconds to know in advance if there is a connection problem?
 
Upvote 0

vangogh

Active Member
Licensed User
Longtime User
the socket object has no error event, but only the "connected" events

(this is what I read in the B4A HelpViewer 0.93)

and the asyncstream error event doesn't fire after a mystream.write, if there is no connection...

(this is what I see):sign0161:
 
Upvote 0
Top