'This test verifies transport socket read state after multiple
pause/resumeProducing calls.'

def test_stopStartReading(self):

    sf = ServerFactory()
    reactor = sf.reactor = self.buildReactor()
    skippedReactors = ['Glib2Reactor', 'Gtk2Reactor']
    reactorClassName = reactor.__class__.__name__
    if ((reactorClassName in skippedReactors) and platform.isWindows()):
        raise SkipTest('This    test    is    broken    on    gtk/glib    under    Windows.')
    sf.protocol = StopStartReadingProtocol
    sf.ready = Deferred()
    sf.stop = Deferred()
    p = reactor.listenTCP(0, sf)
    port = p.getHost().port
    def proceed(protos, port):
        "\n                                                Send    several    IOCPReactor's    buffers'    worth    of    data.\n                                                "
        self.assertTrue(protos[0])
        self.assertTrue(protos[1])
        protos = (protos[0][1], protos[1][1])
        protos[0].transport.write((('x' * (2 * 4096)) + ('y' * (2 * 4096))))
        return sf.stop.addCallback(cleanup, protos, port).addCallback((lambda ign: reactor.stop()))
    def cleanup(data, protos, port):
        "\n                                                Make    sure    IOCPReactor    didn't    start    several    WSARecv    operations\n                                                that    clobbered    each    other's    results.\n                                                "
        self.assertEqual(data, (('x' * (2 * 4096)) + ('y' * (2 * 4096))), 'did    not    get    the    right    data')
        return DeferredList([maybeDeferred(protos[0].transport.loseConnection), maybeDeferred(protos[1].transport.loseConnection), maybeDeferred(port.stopListening)])
    cc = TCP4ClientEndpoint(reactor, '127.0.0.1', port)
    cf = ClientFactory()
    cf.protocol = Protocol
    d = DeferredList([cc.connect(cf), sf.ready]).addCallback(proceed, p)
    d.addErrback(log.err)
    self.runReactor(reactor)
