Solved

sending stdin to a daemon telnet process??

Posted on 2001-08-04
5
911 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 15

Expert Comment

by:NickRepin
ID: 6352748
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
ID: 6352759
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
ID: 6354703
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
ID: 6401950
did it help?
0
 

Author Comment

by:ivang061698
ID: 6402157
Yes.  Thanks for the tips!
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Table Size and Indexes in SQL Server 6 34
File Watcher and Deleter with Email notification 5 135
Windows Process running 3 66
Dialogbox API leak? 18 116
This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

738 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