Search code examples
androiddelphiindy

How to avoid Indy Socket Error # 13 Access denied exception on Delphi and Android?


I have exactly the same problem shown in
Socket Error # 13 Access denied connecting with FTP

Except that the server is a TIdSimpleServer that the program needs to receive some files

Both <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> (just in case since AFAI it's not required to open sockets) and <uses-permission android:name="android.permission.INTERNET" /> are present in the template and manifest file, and also in he project permissions, but when the program reaches

IdSimpleServer.Port := 55; 
IdSimpleServer.Listen(20000);

En exception is thrown:
Project servicios.exe raised exception class EIdSocketError with message 'Socket Error # 13 Access denied.'.

I've deleted the AndroidManifest.xml to ensure it is created. It is indeed with the proper permissions. Also tried uninstalling/reinstalling, rebuilding it and rebooting. Nothing works

I´m using Delphi 10.4 on a Lenovo Tab M10 with Android 11

There is some other permission that needs to be set or a TIdSimpleServer property?


Solution

  • Android runs on top of Linux. On 'Nix platforms, using ports below 1024 is restricted to system processes and root users only. So, you will have to use a higher port number.