Hi !
Sorry, english is not my language ..
Reading the post "aSyncStream and flush" by Star-dust in Mar, 9, 23 (I dont know how to put a link here) he post a way to flush data on a asyncstream :
How can I add a sync after flush ?
Example (part) in Java from https://www.tutorialspoint.com/java/io/filedescriptor_sync.htm
I supose that have to get the File descritor from aout and call method sync ... but I dont know how to do that ...
In Time : Thanks Star-dust
Thanks in advance
Rubens Jr.
Sorry, english is not my language ..
Reading the post "aSyncStream and flush" by Star-dust in Mar, 9, 23 (I dont know how to put a link here) he post a way to flush data on a asyncstream :
B4X:
Private socket As Socket
Private astream As AsyncStreams
Private r As Reflector
Private aout As JavaObject
Sub Button1_Click
socket.Initialize("socket")
s.Connect(Addr,Port,3000)
End Sub
Private Sub socket_Connected (Successful As Boolean)
If Successful Then
astream.Initialize(socket.InputStream,socket.OutputStream,"astream")
r.Target=astream
r.Target=r.GetField("aout")
'Log(r.GetField("working"))
aout=r.GetField("out")
astream.Write("MyText".GetBytes("UTF8"))
aout.RunMethod("flush",Null) ' force send
End If
End Sub
Private Sub astream_NewData (Buffer() As Byte)
Log("* " & Buffer.Length)
End Sub
Private Sub astream_Terminated
End Sub
Private Sub astream_Error
End Sub
How can I add a sync after flush ?
Example (part) in Java from https://www.tutorialspoint.com/java/io/filedescriptor_sync.htm
B4X:
try {
fos = new FileOutputStream("test.txt");
fd = fos.getFD();
// writes byte to file output stream
fos.write(b);
// flush data from the stream into the buffer
fos.flush();
// confirms data to be written to the disk
fd.sync();
I supose that have to get the File descritor from aout and call method sync ... but I dont know how to do that ...
In Time : Thanks Star-dust
Thanks in advance
Rubens Jr.