title: Casting Struct to unsigned char * for IPC needs
body: <p>I have a struct:</p>
  
  <pre><code>typedef struct _message
  {
  
      int mode;
      char system[25];
      ...
  
  }message;
  </code></pre>
  
  <p>I would like to send this across to another process via domain sockets :  </p>
  
  <pre><code>message msg;
  
  //populate msg
  ....
  
  unsigned char * data = &amp;msg;
  
  //allocate IPC buffer
  
  unsigned char * ipc_buffer;
  ipc_buffer = get_ipc_buffer(sizeof(message));
  
  //Copy
  memcpy(ipc_buffer,data,sizeof(message));
  
  //Send
  
  send_ipc_msg(ipc_buffer,sizeof(message);
  
  //At the receving end
  
  recv_ipc_msg(ipc_rcv_buffer,sizeof(ipc_rcv_buffer));
  
  ipc_message* data = (message*)ipc_rcv_buffer;
  
  //Access members
  
  data-&gt;mode;
  </code></pre>
  
  <p>I think it is OK to just cast the struct to (unsigned/signed char*) copy it to a IPC buffer and send it over UDP domain socket since it is sent within given platform. Or Should I still be worried about the alignment issues and struct packing with the above mentioned way of direct casting and not using serailization?</p>