Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 01-26-2009, 07:59 AM   #1
LQ Newbie
Registered: Jan 2009
Posts: 5

Rep: Reputation: 0
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 .
Old 01-26-2009, 05:07 PM   #2
Registered: Jan 2003
Location: Poland, Warsaw
Distribution: LFS, Gentoo
Posts: 591

Rep: Reputation: 32
Look at
Maybe it is what you are looking for.
Old 01-27-2009, 02:57 PM   #3
LQ Newbie
Registered: Jan 2009
Posts: 5

Original Poster
Rep: Reputation: 0
Thanks much the information you have supplied has led me to netcat and it seems to function in the manner I would like. I am currently having some struggles with the the processing of the <STDIN> from my executable.

netcat -v -v IPaddress port -e ./

Within "" I do the following to get the user input:
$sLine = "";
$sLine = <>;
print = "Received: $sLine\n\r";

I receive the warning "Use of uninitialized value in concatenation (.) at ./"

I expected the program to wait till there was information to the <STDIN> before processing. This particular problem is likely because of my relative newness to linux.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Handling stdin and stdout in a daemon inakizi Programming 4 12-13-2007 12:13 AM
Details of stdin and stdout pixellany Linux - Newbie 1 01-11-2006 02:21 PM
stdout stdin Furlinastis Linux - Newbie 3 08-12-2005 12:00 AM
Which function does TCP call to handover a packet to IP? jamesbond Programming 1 06-04-2003 06:30 AM
stdin -> port -> stdout acid_kewpie Linux - Networking 5 04-12-2002 07:01 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:18 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration