Can't listen on ports < 1024 in linux
Hi,
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.
Re: Can't listen on ports < 1024 in linux
What you could try doing is start 2 Java processes (use Runtime to start a second process), then communicate between the two processes either using the streams provided, or have one process forward all information from port 80 to a different port (say 5000), then your non-root process can just read from port 5000.
Re: Can't listen on ports < 1024 in linux
Yes, or I could just use NAT forwarding :)
However, my goal is to develop a simple "dispatcher" for incoming tcp connections (like Apache web server has got it), so that one root process can accept connections and dispatch its handle (or some other object) to oter non-root processes for handling. But I'm not sure how to do this in Java. In native win32 or linux programming, this is widely used and very possible.
Thanks for your help :)