How can I handover Stdin/Stdout Operations over TCP to a client initiated program?
I am a little new to Linux but I am familiar with the process of setting up a server that talks over TCP/UDP using xinetd. In the case of a server the services and programs such as xinetd facilitate much of the negotiation then handover the execution to the server defined in the configuration file. All Stdin/Stdout operations are then redirected over the network.
service myserver
{
flags = REUSE
socket_type = stream
wait = no
user = root
server = /usr/sbin/myprogram
log_on_failure += USERID
disable = yes
}
I now need my server to act as a client. Is there a way for xinetd, or another program, to initiate a TCP connection and then handover execution to a script/program. I have been able to write a perl script which makes a socket connection and then forces print to the handle of the socket. I believe there should be a way for me to call my program within here and have it execute just like it does in xinetd.
*****************************
example perl program
$sock = IO::Socket::INET->new(Listen => 5,
LocalAddr => 'localhost',
LocalPort => 9000,
Proto => 'tcp');
print $sock "Output over TCP";
*not actual code*
print $sock ./myprogram
**********************
If anything is unclear please let me know.
Thanks .
HD
|