How do I know that data written to a shared memory segment in Unix is stored properly

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kumarvegeta
    New Member
    • Mar 2012
    • 1

    How do I know that data written to a shared memory segment in Unix is stored properly

    Hello all,

    I am trying to write a client/server application that takes input to an array of structures from the user,stores the data in a shared memory segment and then writes the same to a file when I close the application. How do I get started? And how do I ensure that the server stores the data correctly? Also, the server needs to be a concurrent server that accepts connections from multiple clients.
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    Question: why do you need to shut down server?

    anyway,
    1. Use TCP not UDP
    2. When you accept an Connection Request open it with new Thread
    3. When you write data to file it returns the number of bytes, you can verify it. You can also verify the written data, but its pointless
    4. When you use shared memory make sure to lock the memory segment so that other thread cannot use this.
    5. You can save your data before application close normally. You can also use signal to detect close request from somewhere other then application itself, look at the link, also read this link, it has example to show how to handle signal

    Comment

    Working...