'If the socket connected, socket reads with an immediate
connection refusal are ignored, and reading stops. The protocol\'s
C{connectionRefused} method is called.'

def test_connectedReadImmediateError(self):

    udp._sockErrReadRefuse.append((-6000))
    self.addCleanup(udp._sockErrReadRefuse.remove, (-6000))
    protocol = KeepReads()
    refused = []
    protocol.connectionRefused = (lambda : refused.append(True))
    port = udp.Port(None, protocol)
    port.socket = StringUDPSocket(['a', socket.error((-6000)), 'b', socket.error(EWOULDBLOCK)])
    port.connect('127.0.0.1', 9999)
    port.doRead()
    self.assertEqual(protocol.reads, ['a'])
    self.assertEqual(refused, [True])
    port.doRead()
    self.assertEqual(protocol.reads, ['a', 'b'])
    self.assertEqual(refused, [True])
