'The transport of a protocol connected with L{IReactorTCP.connectTCP} or
L{IReactor.TCP.listenTCP} can have its I{SO_KEEPALIVE} state inspected
and manipulated with L{ITCPTransport.getTcpKeepAlive} and
L{ITCPTransport.setTcpKeepAlive}.'

def test_tcpKeepAlive(self):

    def check(serverProtocol, clientProtocol):
        for p in [serverProtocol, clientProtocol]:
            transport = p.transport
            self.assertEqual(transport.getTcpKeepAlive(), 0)
            transport.setTcpKeepAlive(1)
            self.assertEqual(transport.getTcpKeepAlive(), 1)
            transport.setTcpKeepAlive(0)
            self.assertEqual(transport.getTcpKeepAlive(), 0)
    return self._connectedClientAndServerTest(check)
