title: c/c++ - safest way to send time_t over socket
body: <p>I've set up a C++ server/client environment, and am trying to send a time_t value from the server to the client (an useful thing in any server). But I'm coming accross a headache: time_t seems to not be under any size specifications. I'm wondering what is the safest (more portable) way to send time_t over the network.</p>
  
  <p>This is a little example:</p>
  
  <pre><code>time_t T = time(NULL);
  unsigned char * P = (unsigned char *)&amp;T;
  // ... Convert it to network byte order, etc.
  
  // Here, 's' would be the socket, and 'S'
  // the size of the data that is going to
  // be sent
  send(s, P, S, 0);
  </code></pre>
  
  <p>I have two problems:</p>
  
  <ul>
  <li>time_t is not size-fixed</li>
  <li>time_t can be a typedef of a signed or unsigned integral data type</li>
  </ul>
  
  <p>How can I handle that two issues so that I can send it safely between (almost) any architecture?</p>
  
  <p>Thanks in advance.</p>
  
  <p>EDIT: After seeing the same three answers, I find it better to response here. I'm sorry I did not clarify that before. I prefer sending it in 'pure' bytes, although sending it as a string is not a problem. As far as I understand, I would need to keep in mind (again) the signedness and the size of time_t data type in the host system, isn't it? (thanks and sorry)</p>