LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 01-26-2009, 06:59 AM   #1
humandynamo
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 .
HD
 
Old 01-26-2009, 04:07 PM   #2
dorian33
Member
 
Registered: Jan 2003
Location: Poland, Warsaw
Distribution: LFS, Gentoo
Posts: 591

Rep: Reputation: 32
Look at http://cr.yp.to/ucspi-tcp/tcpclient.html.
Maybe it is what you are looking for.
 
Old 01-27-2009, 01:57 PM   #3
humandynamo
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 ./myprogram.pl

Within "myprogram.pl" 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 ./myprogram.pl"

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.
 
  


Reply



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-12-2007 11:13 PM
Details of stdin and stdout pixellany Linux - Newbie 1 01-11-2006 01:21 PM
stdout stdin Furlinastis Linux - Newbie 3 08-11-2005 11:00 PM
Which function does TCP call to handover a packet to IP? jamesbond Programming 1 06-04-2003 05:30 AM
stdin -> port -> stdout acid_kewpie Linux - Networking 5 04-12-2002 06:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:19 PM.

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