>> Are you wrapping your transport with TFramedTransport? In any case, could
>> you
>> post both your client and your server?
>
> But is there a method warp transport? I can't find how to & what to
> warp. Can you give me a example to start a twisted server with thrift.

It depends on whether you're writing a client or a server. For a blocking
(nont-Twisted) client, your code should wrap your chosen protocol in similar
way to:

  # Make socket
  transport = TSocket.TSocket('localhost', 9090)

  # Non-blocking servers need framed transports
  transport = TTransport.TFramedTransport(transport)

  # Wrap in a protocol
  protocol = TBinaryProtocol.TBinaryProtocol(transport)

  # Create a client to use the protocol encoder
  client = Calculator.Client(protocol)

And for a blocking server:

  processor = Calculator.Processor(handler)
  transport = TSocket.TServerSocket(9090)
  tfactory = TTransport.TFramedTransportFactory()
  pfactory = TBinaryProtocol.TBinaryProtocolFactory()

  server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)

Cheers.

Reply via email to