Android Question Simple example to communicate between B4a and delphi

invocker

Active Member
client
B4X:
 socket.Initialize("socket")
socket.Connect("127.0.0.1",1900,0)
astream.InitializePrefix(socket.InputStream,True,socket.OutputStream,"astream")
// *****************
B4X:
Private Sub astream_NewData (Buffer() As Byte)
    Dim strAs String = BytesToString(Buffer,0,Buffer.Length,"UTF8")
Select Case str
           Case "TMSG"
            ToastMessageShow("TMSG",True)
    End Select
'   Log( str)
End Sub
server delphi
B4X:
procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
var
  str: string;
begin
  str := AContext.Connection.IOHandler.AllData();
  if str <> EmptyStr then
  begin
  AContext.Connection.IOHandler.WriteLn('TMSG');
    // do something with received string s
  end;

end;
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Can you provide an example exe which implements such a server which i can start/stop on my PC? Maybe with a memo for the incoming messages and a edit to send something or so.
 
Upvote 0
Top