Click to See Complete Forum and Search --> : Clarification on inheriting windows sockets to a new process


samik
July 27th, 2003, 04:03 PM
Hi,

I am new to Windows API.

Here's what I need to do.

I have created 2 TCP sockets in a process. I want to create a new process which will inherit one of them as stdin and the other as stdout.

My first question is that as sockets are being used in the new process for stdin and stdout, I do need to call WSAStartup, don't I ? The problem here is I will not have the source to the new process in a production environment.

I actually wrote some code to do this. I wrote the code for the new process and did not do a WSA_Startup. When I did a scanf in the new process,
it returned an EOF. GetLastError returned 87 - ERROR_INVALID_PARAMETER. Does this confirm that WSAStartup was needed in the new process ?

Hoping for a quick response as I need the info urgently.

Thanks a lot,
Samik

Andreas Masur
July 28th, 2003, 06:30 PM
Well...'ERROR_INVALID_PARAMETER' does not indicate that winsock was ot initialized. Not initializing winsock would be indicated by 'WSANOTINITIALISED'...

samik
July 28th, 2003, 06:43 PM
I actually did some more digging on msdn and the net. It seemed to me that the only documented way of sharing sockets across processes is

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winsock/winsock/shared_sockets_2.asp


Here too, we need to call some specific Winsock functions in the child process, which in my case is not feasible, as I do not have the source code.