title: Two tcp connections from a client in Twisted
body: <p>Im new to twisted. I have written a client which connects to a server on two ports 8037 and 8038. I understand that the factory creates two connection objects. Now when i press Ctrl-C, it says </p>
  
  <pre><code>Connection Lost Connection to the other side was lost in a non clean fashion.
  Connection Lost Connection to the other side was lost in a non clean fashion. 
  </code></pre>
  
  <p>Below is the code:</p>
  
  <pre><code>from twisted.internet import protocol,reactor
  
  class TestClient(protocol.Protocol):
    def __init__(self):
      pass
  
    def connectionMade(self):
      print "Connected "
      self.sayHello()
  
    def connectionLost(self,reason):
      self.transport.loseConnection()
  
    def sayHello(self):
      self.transport.write("Hello")
  
    def dataReceived(self,data):
      print "Received data ",data
  
  
  
  class TestClientFactory(protocol.ClientFactory):
    def buildProtocol(self,addr):
      return TestClient()
  
    def clientConnectionFailed(self,connectory,reason):
      print "Connection Failed ",reason.getErrorMessage()
  
    def clientConnectionLost(self,connector,reason):
      print "Connection Lost ",reason.getErrorMessage()
  
  reactor.connectTCP("&lt;server_ip&gt;",8037,TestClientFactory())
  reactor.connectTCP("&lt;server_ip&gt;",8038,TestClientFactory())
  reactor.run()
  </code></pre>
  
  <ol>
  <li>How can i make the client close both tcp connections cleanly ?. </li>
  <li>How to call the sayHello() method for only one connection ?</li>
  </ol>
  
  <p>Im new to twisted, so an example would be helpful.</p>
  
  <p>Thanks</p>