Link to home
Start Free TrialLog in
Avatar of thobe
thobe

asked on

inetd for Nt4.0 - stdin/stdout -> socket

How can I write (a kind of) inetd for NT? I have to map stdin and stdout to the socket interface. In UNIX, I use fork, dup and exec to start the requested client. How can I map the stdio of my Thread/Child-Process to the socket created in the father process using wsock32 (or any other sock, if you have one).
Avatar of vinniew
vinniew

This is all possible, I just haven't done it because of the terminal problems....

1.  You would start a command shell ( cmd.exe ).  
2.  You take the process handle and the context handles and use them in a command to redirect stdout/stdin.
3.  I think that the name of the command is StdoutHandle or something similar
4.  Use ReadFile/WriteFile on the handles that are now Stdout/Stdin
5.  You may want to do some light massaging on the lines to remove CR's
6.  Send/grab the info to the sockets.

post more specific questions if you need to .


Avatar of thobe

ASKER

Thanks for your answers, but what I need is: In UNIX, I have a
inet-deamon, which receives requests for services to start.
I have to write a C/C++ Windows-Programm, which waits at a
specific port an then starts some Windows-Programm, I have no
sources etc. It can also be a shell-script or Perl etc. In UNIX, you can easily fork your deamon, call close(stdin) and dup(s) on your socket s and call exec on the requested programm. Then, all
stdin/stdout will be written to the socket. When i try this under
NT with a socket, the dup() returns EBADF, a bad File descriptor.
Because I heared about inet-deamons on NT, it must be possible.
So, I am sorry, but the recent answer can not help me.
Thanks



ASKER CERTIFIED SOLUTION
Avatar of jaba
jaba

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial