Solved

sending stdin to a daemon telnet process??

Posted on 2001-08-04
5
897 Views
Last Modified: 2013-12-03
I need to port an application from Unix to NT/2000.  On Unix, I have spawned a telnet application as a daemon process, and my applications can send information to it using  telnets process ID.  I want to be able to do the same within Windows.  There are two parts to this question:
     1) Within my application, how do I create a new process (running a console telnet application)  which will persist even after the spawning application dies?  I have a console version of telnet;  however, I do not actually need to see the console.  However, I need the telnet process to stay alive even after the spawning application dies so I can have other applications connect to it in the future.
     2) How can I send messages to that telnet process, and have that process receive them as if they were comming from stdin?  I believe I can redirect stdin if that would help.

please include sample code!

Thanks!

0
Comment
Question by:ivang061698
  • 3
  • 2
5 Comments
 
LVL 15

Expert Comment

by:NickRepin
Comment Utility
1) Use just CreateProcess()

2)

INFO: Redirection Issues on Windows 95 MS-DOS Applications
http://support.microsoft.com/support/kb/articles/Q150/9/56.ASP

Q190351 - HOWTO: Spawn Console Processes with Redirected Standard Handles
http://support.microsoft.com/support/kb/articles/Q190/3/51.ASP
0
 

Author Comment

by:ivang061698
Comment Utility
Thanks NickRepin, that's a good start.
There are two differences between what I need and what the HOWTO demonstrates.  Perhaps I can clarify what I need.  I have one application which will create the Telnet process.  This telnet process hopefully will stay alive even after the original application dies.  Then, when other applications are executed, and they want to send commands to this pre-existing Telnet session, they can connect to it and send the commands via redirected standard input.  In unix, you can do this by sending info via a process ID.

0
 
LVL 15

Accepted Solution

by:
NickRepin earned 300 total points
Comment Utility
I see now. So Telnet is an existing application, which uses stdin, and you cannot change it?

I think the following should work:

You create a program which CreateNamedPipe() first, and then CreateProcess("Telnet",...DETACHED_PROCESS...). The named pipe handle must be passed to Telnet as described in the articles above. DETACHED_PROCESS might be used to hide Telnet from the user. The program can now exit. The named pipe must survive, because its handle is duplicated.

Now you can use CreateFile() and WriteFile() to connect and write to the named pipe from another process.

Note that you might need to redirect the stdout of Telnet as well.
0
 
LVL 15

Expert Comment

by:NickRepin
Comment Utility
did it help?
0
 

Author Comment

by:ivang061698
Comment Utility
Yes.  Thanks for the tips!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now