Redirect IO of process to Windows socket

前端 未结 4 580
轻奢々
轻奢々 2021-01-14 02:50

I am new to winsock, I tried to write a server socket that accepts new connection, then it calls an external executable file. How can we redirect the stdin and stdout of the

4条回答
  •  醉话见心
    2021-01-14 03:51

    It's not correct to say that socket handles cannot be used for redirected IO to child processes. We do it all the time for CGI in our web server code. We don't use named or unnamed pipes, or intermediary processes.

    a_mole is correct. You just need non-overlapped sockets.

    You can either use WSASocket, or if you created the socket already with socket (or can't use WSASocket on your target OS, e.g. Pre Windows 7 SP1) you can use setsockopt to set the current thread's SO_OPENTYPE to SO_SYNCHRONOUS_NONALERT

提交回复
热议问题