I am new to ruby and I want to write code which makes shared memory and writes to it.Similar to the C code here:

void main(int argc, char* argv[])
   HANDLE mappedFile = 0;
   int oneSecond  = 1000;
   char* shared = NULL;
   HANDLE eventHnd;

   eventHnd = CreateEvent(NULL, FALSE, FALSE, "TestSharedEvent");

   // STEP 1
   mappedFile = CreateFileMapping(INVALID_HANDLE_VALUE, NULL,
                  PAGE_READWRITE, 0, 4096, "TestSharedMemory");
   printf("CreateFileMapping returned %d\n", mappedFile);
   // STEP 2
   shared = (char*)MapViewOfFile(mappedFile, FILE_MAP_WRITE, 0, 0, 0);
   printf("MapViewOfFile returned %p\n", shared);

   memset(shared, 0, 4096);
   printf("memset worked\n");

   int counter = 0;
   while (1)
      sprintf(shared, "value %d", counter++);
      printf("Sending new string: %s\n", shared);
      // STEP 5


Please suggest .Thanks in advance.

Before you start trying to write such complex code, I would recommend buying a book on ruby. I don't have a ruby book that I would recommend off the top of my head because I'm a Ruby on Rails developer. If you decide you want to go with ruby on rails buy agile web development with rails. I'd recommend looking up the pragmatic programmers and see if they have a book on ruby. I'm sure they do since they are the publisher for the book on rails. Oh one last thing, you can always get free help on the IRC if you go to freenode and join #ruby or if you are interested in ruby on rails join us at #rubyonrails . I hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.