Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to send data client server

What is the best way to handle data that needs to get send to the server? I have an multi thread client, in all threads there is data that needs to get send to the server. But when I launch the server there are some times packets that are send at the same time. So the data is not correct at that time.

I thought, lets make a stack that gets send to the server every x ms. Is this a good way to do this?

like image 669
Laurence Avatar asked May 18 '26 20:05

Laurence


1 Answers

You can use message queue structure. There will only one queue in the server and every time a message arrives at the queue its added to the end of the queue, therefore even the messages are sent at the same time they will be ordered. After that process the message in the queue by dequeuing the messages. There are many open source message queue structures you can use, so you do not have to implement it from scratch. You do not have to wait x seconds to send the data to the server in this structure. This will make your system faster.

Hope it helps

like image 62
Ozgur Dogus Avatar answered May 21 '26 12:05

Ozgur Dogus