Android Question convert my delphi code to b4a

Addo

Well-Known Member
Licensed User
Longtime User
i am using delphi for almost 7 years and i need to convert my client Thread to B4A to work under service

i have read on tha forums on how to use socket and i come up with result like following

thats how to connect

B4X:
Socket1.Initialize("Socket1")
   Socket1.Connect("machine ip" , 27274, 20000)
   ph.KeepAlive(True)

and this is how i write

B4X:
If Socket1.Connected Then
         
tr.Initialize(Socket1.OutputStream)
tr.WriteLine(cmd)
tr.Flush
 End If

but i couldn't figure out how to do the same mechanism of my delphi code under b4a like using thread and readln and read stream continuously if a data available

i just wanted to convert from delphi to b4a
 
Last edited:

OliverA

Expert
Licensed User
Longtime User
Don't change the server. Delphi is taking care of the byte to string conversion for you. Looking at some docs (here www.e-iter.net/Knowledge/Indy9/007828.html#001B. Scroll down to TIdTCPConnection.ReadLn), you have to terminate your strings with LF (if the default has not been changed).
B4X:
CallSub2(Starter, "SendData", Bconv.StringToBytes(typingtxt.Text&"~"&chr(10), "UTF8"))
 
Upvote 0
Top