Android UDP server Access denied

I have a simple UDP server Multi-Platform application written in Embarcadero XE8 C++ Builder.
The app comprises of a button on the main form when when clicked toggles the Server Component Active true or false.
The Server is bound to UDP port 60 ( binding but I get the same error whatever port I use.
I am running the app in the Embarcadero debugger.
When the button is clicked to connect, an Access denied error is given on the Android device from the IDE debugger on the PC and when run further the device indicates an error "Address and Port already in use".
I suspect that this is due to some permissions or missing items from the Android manifest.
I attach the C++ builder source code and the Manifest file contents for reference.

Can anybody help with this, I have been stuck on this for a couple of weeks now.
Roger AlcindorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roger AlcindorAuthor Commented:
By the way, the android device is a Samsung SM-T700 tablet. I also get exactly the same result on an Android Phone
Roger AlcindorAuthor Commented:
forgot to click the embed button, here is the codeAndroidUDPListener.txt
Roger AlcindorAuthor Commented:
I suspect that the issue is due to access rights or permissions because I have written and run a UDP client application on the device which sends to a UDP server on a PC and receives replies from the UDP server.
Introduction to R

R is considered the predominant language for data scientist and statisticians. Learn how to use R for your own data science projects.

> When the button is clicked to connect, an Access denied error is given on the Android device from the IDE debugger on the PC and when run further the device indicates an error "Address and Port already in use".

For the first time connect error "Access denied", that is a permission issue.

And on the second try to connect, the connection was opened but was not closed gracefully (app. terminated), the port will remain open, and hence you get "Address and port already in use".

You may try to enclose the connection attempts in Try-Catch block, where you close the port in case of error.
  try {
    IdUDPServer1->Active = !IdUDPServer1->Active;
    Button1->Text = !IdUDPServer1->Active?"connect":"Dis-connect";
  catch (Exception &VCLException)
    Display("Error: " + VCLException.Message);

Open in new window

PS: Not sure about C syntax though.
Roger AlcindorAuthor Commented:
Ok,  so how can I resolve the permissions issue ?
I attaché a copy of the manifest file
Roger AlcindorAuthor Commented:
I had already tried that but the same error. I had also re-booted both the PC and the Android device but to no avail.
I am considering rooting the Android device but don't wish to invalidate the warranty as it is brand new and I am assured that once rooted and even if subsequently un-rooted the warranty will be void.
Rooting the device is not a solution. Because while it works, it does not allow using the app in other un-rooted devices.

Did you check the firewall?

Mostly it will be the least expected reason.
Roger AlcindorAuthor Commented:
As far as I know, there isn't a firewall. I certainly haven't downloaded one. Is there a firewall installed by default ? It's a Samsung Galaxy Tab model SM-T700.
Sorry, I meant on your PC. The connection could be suppressed, by the firewall, on your PC.

Also add this permission:
<user-permission android:name="android.permission.NETWORK" />
Roger AlcindorAuthor Commented:
Any firewall on my PC is not relevant here as the Android app is listening for traffic from anywhere. the error occurs when the UDP Server is activated which initialises a socket for listening and does not require any traffic arriving from the PC.
I included the manifest in a prior comment and this has the line :
<uses-permission android:name="android.permission.INTERNET"/> which is what I think you mention in your last comment although you say "user-permission" instead of "uses-permission" ?
Roger AlcindorAuthor Commented:
I am waiting on the results of a Samsung remote assistance call that has been arranged for this Friday afternoon (UK time). hopefully this will shed some light on the issue.
Also waiting for a response from EDN (Embarcadero develop network) but I won't hold my breath for that.
> Any firewall on my PC is not relevant here as the Android app is listening for traffic from anywhere.
I was thinking of the PC as part of your tests.

...Samsung remote assistance call
Either them, or you get a reply from Android Experts here.
No single comment so far, I wonder where are they?
Roger AlcindorAuthor Commented:
EDN have not responded, I am expecting a call from Samsung within the next 3 hours
Roger AlcindorAuthor Commented:
I have just received the answer from a similar question ID: 28675115. All the port numbers that I used for testing were less than 1024 and when I used a port greater than 1023 there was no error so I am confident that this was causing the error. I will see what Samsung say nevertheless.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.