I've looked through the site and haven't found any guidance on connecting my QTcpSocket
to my Thrift C++ server. This was the closest match, although the solutions proposed don't work.
Client code (Qt Quick Application):
QHostAddress addr {"104.236.6.118"};
quint16 port {9090};
QTcpSocket socket;
socket.connectToHost(addr, port);
if(socket.state() == QTcpSocket::ConnectedState)
{
qDebug()<<"Connection accepted";
} else
{
qDebug()<<"Connection failed";
}
Server code (Thrift C++):
class testerHandler : virtual public testerIf {
public:
testerHandler()
{
printf("Got an incoming connection....");
}
};
int main()
{
int port = 9090;
shared_ptr<testerHandler> handler(new testerHandler());
shared_ptr<TProcessor> processor(new testerProcessor(handler));
shared_ptr<TServerTransport> serverTransport(new TServerSocket(port));
shared_ptr<TTransportFactory> transportFactory(new TBufferedTransportFactory());
shared_ptr<TProtocolFactory> protocolFactory(new TBinaryProtocolFactory());
TSimpleServer server(processor, serverTransport, transportFactory, protocolFactory);
try
{
server.serve();
}
catch (...)
{
printf("ERROR");
}
return 0;
}
Does anyone have any experience or advice on connecting these?