def clientConnected(client):
            """
            Disconnect the client.  Return a Deferred which fires when both
            the client and the server have received disconnect notification.
            """
            client.transport.write(
                b'some bytes to make sure the connection is set up')
            client.transport.loseConnection()
            return defer.gatherResults([
                onClientConnectionLost, onServerConnectionLost])

            Disconnect the client.  Return a Deferred which fires when both
            the client and the server have received disconnect notification.
            
stackoverflow/venv/lib/python3.6/site-packages/twisted/test/test_tcp.py