hi
following i a code that calculates systems up time in days, hrs, min, sec
after calculation result is sent to client. but through this code we can only send any one paramter mean either day, hrs, min or sec. as a result of this code we get on client side 'days' only.
but i want to send all 4 (days, hrs,min, sec) to client.
int systm_time()
{
char send_data[1024];
if(sysinfo(&sys_info) != 0)
perror("sysinfo");
// Uptime
days = sys_info.uptime / 86400;
hours = (sys_info.uptime / 3600) - (days * 24);
mins = (sys_info.uptime / 60) - (days * 1440) - (hours * 60);
// on server window we get the result
printf("Uptime: %ddays, %dhours, %dminutes, %ldseconds\n",
days, hours, mins, sys_info.uptime % 60);
// this function is used to convert int to char str
sprintf(send_data,"%ddays", days);
// result of days is saved in send_data is beign passed to client through sendto()
sendto(sock, send_data, strlen(send_data), 0,
(struct sockaddr *)&client_addr, sizeof(struct sockaddr));
}