HP Rp7410 BSD Sockets Interface Programmer's Guide - Page 146
secs = tp2.tv_sec - tp1.tv_sec
View all HP Rp7410 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 146 highlights
Using UNIX Domain Stream Sockets Example Using UNIX Domain Stream Sockets if (gettimeofday(&tp1, &tzp) == -1) { perror("pitch time of day failed"); exit(0); } i = bytes; total = 0; /* * Send the data */ while (i > 0) { cc = sendsize < i ? sendsize : i; send_data(s, buffer, cc); i -= cc; total += cc; } /* * Receive the bullet to calculate throughput */ recv_data(s, &bullet, sizeof(struct bullet)); if (gettimeofday(&tp2, &tzp) == -1) { perror("pitch time of day failed"); exit(0); } if (pid) kill(pid, SIGUSR2); /* * Close the socket */ close(s); secs = tp2.tv_sec - tp1.tv_sec; usec = tp2.tv_usec - tp1.tv_usec; if (usec < 0) { secs; usec += 1000000; } msec = 1000*(float)secs; msec += (float)usec/1000; printf("PITCH: %d Kbytes/sec\n", (int)(bytes/msec)); printf("CATCH: %d Kbytes/sec\n", bullet.throughput); printf("AVG: %d Kbytes/sec\n", ((int)(bytes/msec)+bullet.throughput)/2); } 146 Chapter 6