0

We know in Linux platform only root user can bind the privileged ports (port numbers 1-1024). If I try to bind as normal user then we will get an exception. It will just say can't bind port specified.

Is there any Java API to check whether the user who invoked the application has permission to bind the privileged port before trying to bind the port?.

There are chances where the port may be used by some other application. That is different case (port is already in use).

jww
  • 97,681
  • 90
  • 411
  • 885
JavaUser
  • 25,542
  • 46
  • 113
  • 139
  • JVM provides functions that can be used on different OS. You can try system call or JNI. – neohope Dec 05 '19 at 04:42
  • 1
    This might help. https://stackoverflow.com/questions/5117449/check-if-a-user-is-root-in-a-java-application – Ran Dec 05 '19 at 04:50
  • Also see [Allow non-root process to bind to port 80 and 443?](https://superuser.com/q/710253/173513) and [Is there a way for non-root processes to bind to “privileged” ports on Linux?](https://stackoverflow.com/q/413807/608639) – jww Dec 05 '19 at 06:23
  • @Ran , there is a chance a non root user may got bind permission from root user. So non-root users may have bind permission – JavaUser Dec 05 '19 at 07:06

0 Answers0