Yay! I am writing a bunch of C code. type iocpcore provides doIteration (for PosixReactorBase) and a bunch of operation-scheduling methods that are used by ops.py Deferred subclasses performance optimization: reuse overlapped structs (probably worthless) My overlapped struct is bigger by a sizeof(PyObject *) and refers to the callable callback. The struct is malloc'ed when operation is issued and free'ed when GetQueuedCompletionResult returns it. If GetQueuedCompletionStatus never returns it, doIteration was not called enough times. Python iocpcore subclass keeps track of pending ops. On reactor.stop, CancelIo all pending ops' handles, then drain the port (until we have no pending ops, I guess). Need proper error handling for this. -------------------------------------- Layers above this (need to rewrite from scratch, ignoring existing implementation completely). RwHandle -- any handle, implements write buffering and continuous reading. It is also the best candidate for keeping track of multiple pending overlapped ops and keeping enough of them pending. ConnectedSocket(RwHandle) -- handles disconnection semantics DatagramSocket(RwHandle) -- handles datagram semantics. Both for connected and not connected datagram sockets, I guess. Won't be implemented for a while. SocketPort -- Handles a listening socket for arbitrary address families. Handles having multiple pending overlapped accepts (iocpreactor's answer to multiple accepts in one event loop iteration!). Produces ConnectedSocket (or a trivial subclass thereof) instance for each new client. SocketConnector -- Handles a connecting socket for arbitrary address families. Not a base.BaseConnector subclass, but a complete rewrite without all the weird failIfConnected shit. Produces ConnectedSocket (or a trivial subclass thereof) instance when connection succeeds. tcp.Connector, tcp.Port -- absolutely trivial subclasses of appropriate abstract classes with address format specified. Address format specifies family, type, afPrefix. Stores address in custom form and provides accessors to make this whole thing compatible with defaultreactor. I wish I had UNIX domain sockets here to show off design leetness. I wonder if IPX sockets have all the AcceptEx and ConnectEx crap and such. Modules: abstract (RwHandle, ConnectedSocket) client (ConnectedSocket subclass, SocketConnector) server (ConnectedSocket subclass, SocketPort) tcp (Connector, Port) in a misguided attempt to have everything in a separate editor window Retarded GCQS behavior: res = 0, ov = NULL, either timeout or raise exception ov != NULl: res, err, bytes: !=0, _, _: set err to 0, not a failure 0, !=0, _: failure, err from GLE Experiment to distinguish between the last two: If the socket is closed while we have a pending AcceptEx request, it returns with 995 (operation cancelled) If the socket is closed while we have a pending ReadFile request, it returns with 64 (network name no longer available) #If the socket is closed before we post an AcceptEx request, #If the socket is closed before we post a ReadFile request, If remote side disconnects while we have a pending ReadFile request, it returns with ret=0, err=_, bytes=0