KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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. This is a little example: time_t T = time(NULL); unsigned char * P = (unsigned char *)&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); I have two problems: time_t is not size-fixed time_t can be a typedef of a signed or unsigned integral data type How can I handle that two issues so that I can send it safely between (almost) any architecture? Thanks in advance. 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)
Tags (comma-separated)
Save Edits
Cancel