2

In my socket application there is no database, I am trying to send the packet from socket client to the socket server. However the socket server is down and packet sending become failed. Hence the client socket application gets terminated.Once the server is up, I will restart my socket client and the socket client needs to send the failed data.

Is there any best way store the failed data in client socket machine?

My solution:Here I have planned to serialize the failed data and store in a file. Once after starting the client, it will reads the file and deserialize the data; try to send that to server socket. Is my solution have any defects?

Vishwa Dany
  • 327
  • 2
  • 16
  • 2
    There are many ways to solve this problem, like implementing a queue, the queue then delivers the packet - if the delivery is not successful, the queue holds _x_ number of packets in the buffer, until the server comes up and then sends them in FIFO fashion. – Burhan Khalid Apr 19 '17 at 05:58
  • 1
    @BurhanKhalid is right. A queue is a good way to do it. You can simply use an `Queue` object in your application. If you want a persistent queue, you can use something like Redis (easy to install and easy to use) to do it or a message queue server like RabbitMQ. – Dorian Apr 19 '17 at 06:11
  • Thanks a lot. I will investigate on queue. – Vishwa Dany Apr 19 '17 at 06:24

0 Answers0