Opened 13 years ago

Closed 11 years ago

#1716 defect closed duplicate (duplicate)

iocpreactor should use WSA functions for sockets

Reported by: ghazel Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: ghazel Branch:


iocpreactor uses ReadFile and WriteFile on sockets. This can (and does) fail on some windows configurations. WSASend and WSARecv should be used instead.

Attachments (1)

iocp_wsa.diff (11.6 KB) - added by ghazel 13 years ago.
WSASend and WSARecv ops

Download all attachments as: .zip

Change History (7)

comment:1 Changed 13 years ago by ghazel

I added WSASend and WSARecv to the iocp ops, and fixed a few other small things (should call WSAGetLastError for WSA functions), diff attached.

Changed 13 years ago by ghazel

Attachment: iocp_wsa.diff added

WSASend and WSARecv ops

comment:2 Changed 13 years ago by Jean-Paul Calderone

Cc: ghazel added
Owner: changed from Glyph to PenguinOfDoom

Can you describe the configurations which this fixes?

comment:3 Changed 13 years ago by ghazel

Not in enough detail to reproduce the problem, unfortunately. I have two machines here with identical hardware and the same OS (xp sp2) but different software. One of them (a fairly standard install of IBM software) does not work with Read/WriteFile (they give error 87 - 'invalid arguement' on the first read) but works great with WSARecv/Send.

comment:4 Changed 13 years ago by ghazel

These people agree that the WSA functions should be used instead:

Network Programming for Microsoft Windows (Microsoft Press) - Anthony Jones, Jim Ohlund

pg.261 where it says:

On a final note, Winsock applications should not use the ReadFile and WriteFile Win32 functions for processing I/O on a completion port in Winsock. These functions do feature an OVERLAPPED structure and can be successfully used on a completion port; however, the WSARecv and WSASend functions are better optimized for processing I/O in Winsock 2. Using ReadFile and WriteFile involves making many more unnecessary kernel/user mode procedure call transitions, thread context switches, and parameter marshaling, resulting in a significant performance penalty.

comment:5 Changed 11 years ago by PenguinOfDoom

Resolution: duplicate
Status: newclosed

This is fixed in the new iocpreactor code. See #1760

comment:6 Changed 8 years ago by <automation>

Owner: PenguinOfDoom deleted
Note: See TracTickets for help on using tickets.