b'\n_START_ARTICLE_\nTwisted (programari)\n_START_SECTION_\nExemple\n_START_PARAGRAPH_\nExemple simple de client TCP\xc2\xa0:_NEWLINE_# Copyright (c) Twisted Matrix Laboratories.# See LICENSE for details."""An example client. Run simpleserv.py first before running this."""from __future__ import print_functionfrom twisted.internet import reactor, protocol# a client protocolclass EchoClient(protocol.Protocol):_NEWLINE_    """Once connected, send a message, then print the result."""_NEWLINE_    _NEWLINE_    def connectionMade(self):_NEWLINE_        self.transport.write(b"hello, world!")_NEWLINE_    _NEWLINE_    def dataReceived(self, data):_NEWLINE_        "As soon as any data is received, write it back."_NEWLINE_        print("Server said:", data)_NEWLINE_        self.transport.loseConnection()_NEWLINE_    _NEWLINE_    def connectionLost(self, reason):_NEWLINE_        print("connection lost")class EchoFactory(protocol.ClientFactory):_NEWLINE_    protocol = EchoClient_NEWLINE__NEWLINE_    def clientConnectionFailed(self, connector, reason):_NEWLINE_        print("Connection failed - goodbye!")_NEWLINE_        reactor.stop()_NEWLINE_    _NEWLINE_    def clientConnectionLost(self, connector, reason):_NEWLINE_        print("Connection lost - goodbye!")_NEWLINE_        reactor.stop()# this connects the protocol to a server running on port 8000def main():_NEWLINE_    f = EchoFactory()_NEWLINE_    reactor.connectTCP("localhost", 8000, f)_NEWLINE_    reactor.run()# this only runs if the module was *not* importedif __name__ == \'__main__\':_NEWLINE_    main()'