Re: Stdin/stdout tunneling through sockets to child process under Win9X

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: JJ (jjjj_at_nospam.com)
Date: 12/06/04


Date: Sun, 5 Dec 2004 20:17:23 -0500

I don't think this can be done with Windows 9x. You need a helper process
that sits between your process and the other process, passing the data back
and forth to the child via pipes.

See this article (note the last bullet):

http://support.microsoft.com/kb/q150523/

The article says this:

It is also common practice on Windows NT to set the standard handles
(standard input, output, or error) of the child process to the socket
handle. In such cases, the child process usually does not know that its
standard handles are actually sockets.

Windows 9x differs from Windows NT/Windows 2000 in the following manner:

- Socket handles are not inheritable when created. To ensure that a child
process can obtain and use a socket handle created in the parent, the handle
must be explicitly duplicated using the Win32 API DuplicateHandle. Set the
bInheritHandle parameter of the API to TRUE.

- Socket handles cannot be set to the standard handles of the child process.
A programmer may use other mechanisms to pass the socket handle to the
client, such as passing the handle values as command line arguments so that
the child process can simply look at its argument vector.

"Bedrich Svoboda" <bedrich.svoboda@post.cz> wrote in message
news:%23i8TA8q2EHA.524@TK2MSFTNGP09.phx.gbl...
>I have examined that example before. As you can see, my code is quite
>similar, but it uses sockets instead of anonymous pipes (I need to use
>telnet from different machines). That Microsoft code works well under both
>Win9X and Win2K+; my code with sockets works under Win2K+ only.
>
> The problem is that I haven't found any sample or description, on how
> sockets should behave when passed to child processes. Note that there is
> many sources describing handle passing to child processes OR using sockets
> as Windows handles, but none describing it together with information about
> Winsock/Windows kernel versions.
>
> "Eugene Gershnik" <gershnik@hotmail.com> wrote in message
> news:uTJyYqm2EHA.2876@TK2MSFTNGP12.phx.gbl...
>> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/creating_a_child_process_with_redirected_input_and_output.asp
>
>



Relevant Pages

  • Re: passing a socket to a spawned process.
    ... >> you will have the socket after the fork. ... >> From what I was able to work out, it is not possible in Windows. ... > While I have never passed a socket between python processes, ... > Now the child process should have everything it needs to listen on the ...
    (comp.lang.python)
  • Re: Why RosAsm Breaks on a large number of symbols
    ... focus - the point of interest was whether you could duplicate windows ... in memory, and kernel mode memory is something you don't want to waste too ... how long it takes before the child process terminates. ... By "register preservation", I mean "make sure that, on exit of your ...
    (alt.lang.asm)
  • Re: Socket.Disconnect Method
    ... Although the exception list in the MSDN documentation ... Windows XP SP2. ... An error occurred when attempting to access the socket. ... use the SocketException.ErrorCode property to obtain the specific error code. ...
    (microsoft.public.vsnet.general)
  • Re: Socket.Disconnect Method
    ... method that only worked on platforms prior to Windows ... method is supported on Windows 2000 and Windows 98, ... An error occurred when attempting to access the socket. ... It looks to me like the underlying error code could have been: ...
    (microsoft.public.vsnet.general)
  • Re: Tcp Socket Close Event
    ... Shutdown | TcpClient Members | Managed Extensions for C++ ... Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows ... SocketExceptionAn error occurred when accessing the socket. ... associated with the TcpClient. ...
    (microsoft.public.dotnet.languages.vb)