Results 1 to 3 of 3

Thread: Indy TCP sockets X Delphi XE8 (Android)

  1. #1

    Indy TCP sockets X Delphi XE8 (Android)

    Hi

    My code for Windows its working!!!

    But for Android not, I'm using FireMonkey, here is my source code:

    Server:
    Code:
    procedure TForm1.IdTCPServer1Execute(AContext: TIdContext);
    var
      MIRec: string;
    begin
      MIRec := AContext.Connection.IOHandler.ReadLn;
      Memo1.Lines.Add('recebido = ' + MIRec);
    end;
    Client:

    Code:
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      try
        form1.IdTCPClient1.Host := 'localhost';
        form1.IdTCPClient1.Port := 4040;
        form1.IdTCPClient1.Connect;
      except
        ShowMessage('Connection Unsuccessful: ');
      end;
      form1.IdTCPClient1.IOHandler.WriteLn(edit1.text);
    end;
    What can be wrong on Android?

    Thanks
    Last edited by SilverWarior; 15-03-2018 at 03:53 AM. Reason: Added code formatting

  2. #2
    Is your server also listening on LoclaHost or is it perhaps listening on your WiFi connection

    According to SO question here (https://stackoverflow.com/questions/...ket-on-android) it seems that LocalHost address and WiFi address are not part of the same network. Acording to the answeres there local host IP address is usually specified as 127.0.0.1 while WiFi card is assigned to 0.0.0.0 IP address. So if Android is also using subnet mask 255.255.255.0 by default as it is on wondows then the two network addresses are not visible between each other since they are not part of the same network.
    Last edited by SilverWarior; 15-03-2018 at 04:36 AM.

  3. #3
    Quote Originally Posted by SilverWarior View Post
    Is your server also listening on LoclaHost or is it perhaps listening on your WiFi connection

    According to SO question here (https://stackoverflow.com/questions/...ket-on-android) it seems that LocalHost address and WiFi address are not part of the same network. Acording to the answeres there local host IP address is usually specified as 127.0.0.1 while WiFi card is assigned to 0.0.0.0 IP address. So if Android is also using subnet mask 255.255.255.0 by default as it is on wondows then the two network addresses are not visible between each other since they are not part of the same network.
    Thank you my friend!!!

    Changing to 0.0.0.0 on my android application its working!!!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •