Black7
Black7

Reputation: 21

Qt Remote Object - Do some requests at same time to a server

I use the qt remote object to transfer data between my server and my client. When my client do two calls at the same time to my server, my server it's not able to respond two response at the same time.

In my server, I have this code :

AService aService; 
BService bService;

QRemoteObjectHost srcNode(QUrl("tcp://" + (QString) "ipOfServer" + ":serverPort"));
srcNode.enableRemoting(&aService);
srcNode.enableRemoting(&bService);

My question is, How to put each call to my server on a separate thread. So, if my server receive a call for the aService and a call to the bService, each call is runned on a separate thread.

In the qt documentation, I find nothing on multi threading the QRemoteObjectHost, anyone have an issue ?

Upvotes: 2

Views: 143

Answers (1)

Brett Stottlemyer
Brett Stottlemyer

Reputation: 2852

If you really want to respond in different threads, the easiest way to do that would be to have multiple nodes, with the nodes in their own threads. That would mean there are different address for each node, but that can be worked around by using a registry. This would leverage Qt's QueuedConnections, automatically running the processing in different processes.

Remote Objects should have no issue responding to multiple requests, though, so I wonder if there is a different underlying issue.

Note: "At the same time" is interesting here. The Qt event loop will receive one or the other request first and will handle them in the order received. This happens so fast in the event loop, though, it shouldn't be observable especially when taking into account network latencies.

Upvotes: 0

Related Questions