S
S
sbh2018-08-29 13:56:35
Qt
sbh, 2018-08-29 13:56:35

What is the best way to implement the exchange between client and server?

There is a client, there is a server.
The client sometimes receives jobs from the server and sends information to the server.
What is the best way to implement receiving tasks from the server?
The stupid option of polling every 10 seconds is not suitable.
I think that it would be ideal by analogy with push messages as on mobile devices - the server sends information to clients so that they apply for it.
Who implemented such things.
For example, you can take a situation and paint on it - in an arbitrary messenger, someone added you to the address book and you should receive a notification about this. The client is a desktop application.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Phantomouse, 2018-08-29
@sbh

There are no miracles, and PUSH is just a user-friendly interface. It is based on just the same constant connection between the client and the server via TCP Socket . The connection is established for as long as the client is online. If necessary, the server sends a notification to the client about new messages. Simply, a layer from Google, Apple and others acts as a client and server, and your application becomes a subscriber to their transport packets.
You can use to create a similar WebSocket system, which is easier to organize if you ate some kind of PHP on the server side, or a classic socket if the server allows you to run arbitrary binary applications and you know how to write them. WNS is available for apps on the Universal Windows Platform (app store platform for Win10) .
Judging by the epithet "stupid" to the "poll every 10 seconds" option, you are already familiar with the concept of REST . However, this is most likely the best option for you. Classical socket programming is, by today's standards, low-level programming, and the question requires a good understanding of how a LAN works. You need to climb there only if you have a really high-loaded project (no, ten requests from clients per second is not High Load: D).
I cannot give advice on the technology stack without knowing the essence of the problem). If you are already writing a client in QT - C ++ will help you for the server side as well. If web clients are not planned in the future, you can go down to the levels of a regular TCP socket. I'm sure QT has libraries to support these things as well. If done on WebSocket, in the future it will be possible to make HTML5/JavaScript clients embedded in web pages without much movement from the server side.

M
Mysterion, 2018-08-29
@Mysterion

long polling or socket server.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question