code: def dataReceived(self, data):
          
          def write(result):
              print "Writing %r" % result
              self.transport.write(result)
          d = self.d()
          d.addCallback(write)  # errors are silently ignored!
          d.callback(data)
docs: After receiving the data, generate the deferreds and add myself to it.