Results 1 to 2 of 2
  1. #1
    burek is offline Member
    Join Date
    Dec 2010
    Rep Power

    Question Can't listen on ports < 1024 in linux


    This is not quite a noobie question, so I would really appreciate your opinion on this topic.

    Is there any way to implement something like Apache web server does:
    - one process running as root, listening on port 80 (proc_root)
    - other processes running as non-root (proc_user)
    in that way proc_root can accept() incoming tcp/ip connections and pass some information (handle, object, anything) to proc_user, which will continue handling that connection?

    The problem is that I don't want my user process to run as root, just to be able to listen on port < 1024 (in linux). Also, I'm more interested in methods of passing sockets between java processes, if that is possible at all in Java.

    Is there any trick to do this in Java?
    Thanks in advance.

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Rep Power


    yes, this is possible, this is how apache and tomcat usually connect with mod_jk. where i have apache started a root user to bind to port 80. then my tomcat instance runs as a non-root user on the standard ajp13 port, so requests thru apache are sent thru the mod_jk connector to tomcat. it should likely be possible to do this pattern with two java processes too. the trick is the operating system level where we 'run this process as a given user'. I don't know of a way to have a process ran as another user inside java, you would need a shell script wrapper to start it up, or at least have the java program invoke a "su - $user" kind of launch child process thing.

Similar Threads

  1. serversocket listen connection
    By gisler in forum Networking
    Replies: 1
    Last Post: 12-17-2009, 03:57 AM
  2. Listen for changes in a JTextField
    By matzahboy in forum AWT / Swing
    Replies: 5
    Last Post: 10-13-2009, 04:15 PM
  3. Cannot Listen TAB key
    By sh4dyPT in forum AWT / Swing
    Replies: 5
    Last Post: 07-16-2009, 01:45 PM
  4. Replies: 6
    Last Post: 04-08-2009, 04:05 AM
  5. how to listen for buttons between jpanels?
    By pjr5043 in forum New To Java
    Replies: 17
    Last Post: 09-29-2008, 03:37 AM

Posting Permissions

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