Can Perl do this task???

A

at

Unix system: I have a compiled application that can only use STDIO
but I now need it to talk to a remote server using TCP on a particular
socket.

I've tried some hardware type interfaces in between but its difficult
if not impossible to control the port assignments.

I was thinking that I could create a perl program and via a pipe
connect it to my compiled application and the perl program could use a
module like Sockets::IO to connect to and pass the IO through both
ways. Sometimes the traffic is incoming and sometimes its outgoing.

Am I crazy or would this be possible and viable? Any other
suggestions also appreciated.

Thanks
 
B

Ben Morrow

R.Mariotti(at)FinancialDataCorp.com (Bob Mariotti) said:
Unix system: I have a compiled application that can only use STDIO

ITYM stdin/stdout?
but I now need it to talk to a remote server using TCP on a particular
socket.

I was thinking that I could create a perl program and via a pipe
connect it to my compiled application and the perl program could use a
module like Sockets::IO to connect to and pass the IO through both
ways. Sometimes the traffic is incoming and sometimes its outgoing.

Am I crazy or would this be possible and viable? Any other
suggestions also appreciated.

This is perfectly possible, indeed relatively trivial... unless you want
to go for maximum performance.

A simpler way of doing it is with netcat or socat.

Ben
 
T

toylet

Unix system: I have a compiled application that can only use STDIO
I was thinking that I could create a perl program and via a pipe
connect it to my compiled application and the perl program could use a
module like Sockets::IO to connect to and pass the IO through both
ways. Sometimes the traffic is incoming and sometimes its outgoing.

I think it's doable. What's really holding you from doing a test?
 
T

thumb_42

Bob Mariotti said:
Unix system: I have a compiled application that can only use STDIO
but I now need it to talk to a remote server using TCP on a particular
socket.

I've tried some hardware type interfaces in between but its difficult
if not impossible to control the port assignments.

I was thinking that I could create a perl program and via a pipe
connect it to my compiled application and the perl program could use a
module like Sockets::IO to connect to and pass the IO through both
ways. Sometimes the traffic is incoming and sometimes its outgoing.

Am I crazy or would this be possible and viable? Any other
suggestions also appreciated.

It's viable and possible too, just look at what rsh/ssh do. :)

Speaking of which, why not just use ssh?

Jamie
 
J

James Willmore

Unix system: I have a compiled application that can only use STDIO
but I now need it to talk to a remote server using TCP on a particular
socket.

I've tried some hardware type interfaces in between but its difficult
if not impossible to control the port assignments.

I was thinking that I could create a perl program and via a pipe
connect it to my compiled application and the perl program could use a
module like Sockets::IO to connect to and pass the IO through both
ways. Sometimes the traffic is incoming and sometimes its outgoing.

Am I crazy or would this be possible and viable? Any other
suggestions also appreciated.

Try reading `perldoc perlipc` to see if what you want to do is listed in
there. It *seems* like you're over complicating something simple -or- I'm
missing something rather complex :)

You could, maybe, use two fifo's. One for writing and one for reading.
Both the script and the application could use these fifo's to communicate.
There is a section in perlipc that covers fifo's, as well as some other
tactics to deal with this situation.

HTH

--
Jim

Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.

a fortune quote ...
Innovation is hard to schedule. -- Dan Fylstra
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top