Dmitry Timoshkov a écrit :
"Eric Pouech" pouech-eric@wanadoo.fr wrote:
For asynchronous read operations, hFile can be any handle opened with the FILE_FLAG_OVERLAPPED flag by the CreateFile function, or a socket handle returned by the socket or accept function.
which means that ReadFile() only works on socket for async reads, not sync reads. I'll precise this.
Did you actually test this? We need a knowledge, not a speculation.
I did. See attached test and it fails on XP. Note that ReadFile works on socket (overlapped op), while WriteFile (synchronous operation) doesn't.
Your test passes on win2k SP4 for me, but hangs on win98. Uncommented WriteFile call failes and doesn't change a previous error value, but that might be due to different reasons: missing OVERLAPPED pointer, incompatible socket open mode, or something else.
yeahh, you're right. I found what's going wrong. By default, WS2 opens the socket in overlapped mode, hence the error in Read/Write File (while the send/recv and other WS functions should handle this gracefully). BTW, our WS implementation doesn't use the right open mode by default (which is overlapped) A+