The client program should send the following values to the server:
1 байт - значение дня (1-31) первой даты, 1 байт - значение месяца (1-12) первой даты, 2 байта - unsigned short, год (0-9999), в СЕТЕВОМ порядке байтов, 1 байт - значение часов (hh, 0-23), 1 байт - значение минут (mm, 0-59), 1 байт - значение секунд (ss, 0-59),
And we have a function to send:
int send(int sockfd, const void *buf, int len, int flags);
I understand that a void pointer can be cast to some other type. For example, char *. Then I can send lines with the necessary information. For example, 05/24/2014.
How to send a two-digit 24 bytes in one byte? If you send in 24 lines, then there will be 2 bytes and you need to follow the network order. Can you send characters by character? Then two bytes will be sent anyway. Or the task "meant" to send one byte for one send? Then there will be two send for date 24 and still the values of the day were not sent to one byte.
And if it is a month or a day that has an insignificant zero in front, as for 05 months. Then is null also needed to be transmitted?
Another question about network order: we have host-to-network-short and host-to-network-long functions. How to check whether the value is translated correctly?
unsigned char x = 24;
- here you have one byte with value 24 ... When do you writeint x = 1000000000;
- do not you think by chance thatx
in memory takes 10 bytes? ... - Harrychar
is a number? Likeshort
,int
,long
, etc. Usually with a range of-128
to127
. - HolyBlackCat 5:41 pm