REQUIREMENT
A Client Server Application
Communication will be done by thrift
Server will be running in background or invoked through terminal with no GUI
Client will be Qt based
Current Scenario and problem
Currently, the server uses TNonBlockingServer
with certain number of threads(using threadmanager)
Clients connect to the server and does the job.
But, there is a certain requirement where if my server is not running and client tries to connect to it then a message box should be displayed in client's screen.
Currently program just gives a segmentation fault, so i tried using try catch, which didn't work. Upon searching i noticed that Qt doesn't support Exceptions.
Upon some more searching i came across This, but this seems to be using QT(and I still don't know if my problem can be resolved by this)
Server Code :
shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
shared_ptr<workerHandlerHandler> handler(new workerHandlerHandler());
shared_ptr<TProcessor> processor(new workerHandlerProcessor(handler));
shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(15);
shared_ptr<PosixThreadFactory> threadFactory = shared_ptr<PosixThreadFactory>(new PosixThreadFactory());
threadManager->threadFactory(threadFactory);
threadManager->start();
TNonblockingServer server(processor, protocolFactory, port,threadManager);
server.serve();
Client connects using
boost::shared_ptr<TSocket> socket(new TSocket(serverip.toUtf8().data(), 59999));
boost::shared_ptr<TTransport> transport(new TFramedTransport(socket));
boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
workerHandlerClient client(protocol);
transport->open();
int pingValue = client.ping();
transport->close();