bash - xinetd / netcat - redirecting stdin/stdout -
i have simple xinetd controlled script wraps simple java application listens on given port. xinetd talks via stdin/stdout, use netcat redirect traffic to/from java app. @ moment have following configuration.
xinetd
service my_server { type = unlisted disable = no socket_type = stream protocol = tcp wait = no user = root port = 2177 log_on_success += duration host userid server = /opt/stuff/my_server.sh }
my_server.sh
port=2111 # start java process on given port java -jar /opt/stuff/myserver.jar "$port" & # redirect traffic using netcat retry_counter=0 until nc -v 127.0.0.1 ${port} let "retry_counter++" echo "retrying... (${retry_counter})" >> /var/log/smpp_nc sleep 0.1 done
it seems netcat job of sending data app, not other way around... help/hints appreciated!
assuming you're in control of java server code, you're adding layer of redirection isn't needed. instead of configuring xinetd call shell script, configure call java application. use system.in , system.out java - simple!
your server able use stdin/stdout once it's hooked xinetd.