My project has two programs: Parent and Child.
In Parent: has one socket waiting connection from client. When Parent accepts connection, it generates Child process and passes socket to Child.
SOCKET newSock = accept(listenSock, 0, 0);
char cmd[1024];
sprintf(cmd, "%s %d", "Child.exe", newSock);
result = CreateProcess( NULL, cmd, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &startupInfo, &processInformation);
Client and Child process transfer data successfully.
But when I searches Google and some people wrote that : must call function WSADuplicateSocket(), after that pass socket to child process.
Pleas help me show the different between the two ways?
If i don't call WSADuplicateSocket() whether my program has any error or not?
Thanks!