title: Port forwarding with xinetd
body: <p>I want to forward xinetd connection to another local port (say 12345). I based my solution  on CentOS/Redhat documentation Chapter 17. <a href="http://www.centos.org/docs/4/html/rhel-rg-en-4/s1-tcpwrappers-xinetd-config.html" rel="nofollow noreferrer">TCP Wrappers and xinetd, article 17.4.3.3</a>. In the example the configuration starts a daemon and also redirects the traffic to a host:port. The doco say it should be able to forward to different port on the same system too.</p>
  
  <p>My current goal is to  starts a daemon (say testsmpp) at any connection on port 12345 and redirect the stream to a particular port (say 54321). The tricky bit is I don't want the daemon (testsmpp) to read from STDIN, instead it should be able to read from the port where the xinetd is forwarding the traffic to.</p>
  
  <p>I created a service under /etc/service e.g</p>
  
  <pre><code>testsmpp    12345/tcp
  </code></pre>
  
  <p>And my xinetd configuration for the daemon is</p>
  
  <pre><code>service testsmpp
  {
      sock_type =     stream
      protocol =      tcp
      wait =          no
      user =          root
      server =        /home/me/bin/testsmpp        
      redirect =      54321
  }
  </code></pre>
  
  <p>testsmpp listens on port 54321. The problem is when a connection made from outside, xinetd starts the daemon but do not forward the traffic to 54321. Once the server started I can connect directly to 54321 port but the connection made via xinetd (at port 12345) is not forwarded.</p>
  
  <p>Is server and redirect tags are mutually exclusive? I looked at the discussion about <a href="https://softwareengineering.stackexchange.com/questions/207412/seeking-xinetd-alternative-for-forking-concurrent-servers-in-linux?newreg=c19184b05fc54d948d7417eaf984a782">xinet forking concurrent server</a> but my motivation are slightly different. I want to listen for incoming connection on another port as the other application will communicate with the daemon on that port too in a distributed computing environment.</p>
  
  <p>Any clues much appreciated.</p>