Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Can't listen on ports < 1024 in linux

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question 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.


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default 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.

  3. #3
    Junior Member
    Join Date
    Dec 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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

Similar Threads

  1. How to Create a server socket to listen for incoming connections?
    By JavaPF in forum Java Networking Tutorials
    Replies: 3
    Last Post: October 28th, 2011, 10:02 AM
  2. jSSC library - for easy work with serial ports
    By scream3r in forum Java SE API Tutorials
    Replies: 4
    Last Post: July 19th, 2011, 10:36 AM
  3. List serial com ports of computer
    By mickey in forum Java Networking
    Replies: 2
    Last Post: August 6th, 2010, 02:44 AM
  4. [SOLVED] Listen to two JRadioButton + ons JButton to produce output
    By voltaire in forum AWT / Java Swing
    Replies: 1
    Last Post: May 12th, 2010, 04:46 PM
  5. Replies: 9
    Last Post: June 27th, 2009, 05:05 PM