/** * Rick van der Zwet * Licence: BSD * UDP handshake taken from http://www.abc.se/~m6695/udp.html */ #include "timediff.h" void diep(char *s) { perror(s); exit(1); } int main(int argc, char * argv[]) { printf("Size of .. %li\n", sizeof(uint32_t)); printf("Size of .. %li\n", sizeof(struct timeval)); struct timeval tv; struct tm *tm; struct sockaddr_in si_me, si_other; int s, i, slen=sizeof(si_other); char buf[BUFLEN]; if ((s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1) diep("socket"); memset((char *) &si_me, 0, sizeof(si_me)); si_me.sin_family = AF_INET; si_me.sin_port = htons(PORT); si_me.sin_addr.s_addr = htonl(INADDR_ANY); if (bind(s, (struct sockaddr *)&si_me, sizeof(si_me))==-1) diep("bind"); struct timeval_t packet; for (i=0; itm_hour, tm->tm_min, tm->tm_sec, tv.tv_usec); } close(s); return 0; exit(0); }