Hi Java implementation provides guessProtocolFactory ==> server can support json and binary
-roger > -----Ursprüngliche Nachricht----- > Von: sergiu F [mailto:fs...@yahoo.com] > Gesendet: Freitag, 23. März 2012 14:57 > An: user@thrift.apache.org > Betreff: how to have two protocols on same TServerSocket? > > > Hi, > > It is possible to have two kind of protocols mapped on same port? For > example this code accept clients having json and binary. Code works fine only > if requests from clients come in same order: json,binary,json,binary.... > > thanks > serj > > TServerSocket serverTransport = new TServerSocket(7912); > TJSONProtocol.Factory f = new TJSONProtocol.Factory(); > > TimeServer.Processor processor = new TimeServer.Processor(new > TimeServerImpl()); > final TServer jsonServer = new TThreadPoolServer(new > TThreadPoolServer.Args(serverTransport). > processor(processor).protocolFactory(f)); > > final TServer binaryServer = new TThreadPoolServer(new > TThreadPoolServer.Args(serverTransport).processor(processor)); > > new Thread(new Runnable(){ > @Override > public void run() { > System.out.println("Starting serverJSON on port 7912 ..."); > jsonServer.serve(); > } > > }).start(); > > new Thread(new Runnable(){ > @Override > public void run() { > System.out.println("Starting serverBINARY on port 7912 ..."); > binaryServer.serve(); > } > > }).start();