I've hit upon a problem with WSADuplicateSocket, which I'm using to duplicate a socket for use by a different process. It works find when both processes are running under the same Windows user, but fails with error code 10022 (WSAEINVAL) when they are running under different users.
Specifically, the process calling WSADuplicateSocket is running under an admin user account and the target process is running under the System account.
Searching the web, I've found other references to the issue, but no solutions. Does anyone know of a way to resolve this?
Here's the current code:
bool Duplicate(
SOCKET s,
WSAPROTOCOL_INFO* pSocketInfo,
int targetProcessID,
int& errorNum
)
{
memset(pSocketInfo, 0, sizeof(WSAPROTOCOL_INFO));
if (::WSADuplicateSocket(s, targetProcessID, pSocketInfo)
== SOCKET_ERROR)
{
errorNum = ::WSAGetLastError();
return false;
}
return true;
}