http://bugs.winehq.org/show_bug.cgi?id=58122
Bug ID: 58122 Summary: WSAENOTSOCK error when calling winsock.Send() on duplicated socket Product: Wine-staging Version: 10.4 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: -unknown Assignee: wine-bugs@winehq.org Reporter: digitman63@gmail.com CC: leslie_alistair@hotmail.com, z.figura12@gmail.com Distribution: ---
Process A creates a listening socket, accepts an incoming connection, and obtains a socket handle hSock.
Process A spawns Process B with the InheritHandles flag, passing its own ProcessID and the socket handle hSock as command-line arguments.
Process B calls OpenProcess() to get a handle hSrcProcess for the given ProcessID, then duplicates hSock into hDupSock using DuplicateHandle(hSrcProcess, hSock, GetCurrentProcess(), &hDupSock, ...); Process B successfully receives data from the duplicated socket using winsock.recv(hDupSock, ...).
Process B attempts to send data via winsock.send(hDupSock, ...), but the call fails with WSAENOTSOCK (10038) ("Socket operation on non-socket").
Process B then tries sending the same data using kernel32.WriteFile(hDupSock, ...), and this operation succeeds.
Why does send() fail while WriteFile() works on the same duplicated handle?