views:

18

answers:

0

Hi. I'm trying to transfer socket from the one process to the another process constantly. I'm using WSADuplicateSocket on the master process which always works fine. Then I'm calling WSASocket on the child process. However, I do get WSAEINVAL error from WSASocket once in a while.

I check lpWsaProtocolInfo parameter and it's always good. So I really have no idea how this error could happen?

Master:

int err = WSADuplicateSocket( sockFd, childPID, 
                        (LPWSAPROTOCOL_INFO)sockInfo );

Child:

LPWSAPROTOCOL_INFO lpWsaProtocolInfo = 
    (LPWSAPROTOCOL_INFO)malloc( sizeof( *lpWsaProtocolInfo ) );

memcpy( lpWsaProtocolInfo, sockInfo, sizeof( *lpWsaProtocolInfo ) );

sockFd = WSASocket( AF_INET, SOCK_STREAM, IPPROTO_TCP, lpWsaProtocolInfo, 
                    0, 0 );