HP Rp3440-4 - 9000 - 0 MB RAM Programmer's Manual page 143

Bsd sockets interface programmer’s guide
Hide thumbs Also See for Rp3440-4 - 9000 - 0 MB RAM:
Table of Contents

Advertisement

*/
send_data(ns, &bullet, sizeof(struct bullet));
cc = 0;
if (counter_pid)
kill(counter_pid, SIGUSR1);
if (gettimeofday(&tp1, &tzp) == -1) {
perror("catch time of day failed");
exit(0);
}
/*
* Receive data from the client
*/
total = 0;
i = bytes;
while (i > 0) {
cc = recvsize < i ? recvsize : i;
recv_data(ns, buffer, cc);
total += cc;
i -= cc;
}
/*
* Calculate throughput
*/
if (gettimeofday(&tp2, &tzp) == -1) {
perror("catch time of day failed");
exit(0);
}
if (counter_pid)
kill(counter_pid, SIGUSR2);
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;
bullet.throughput = bytes/msec;
/*
* Send back the bullet with throughput info, then close the
* server socket
*/
if ((cc = send(ns, &bullet, sizeof(struct bullet), 0)) == -1)
{
perror("catch - send end bullet failed");
exit(0);
}
close(ns);
}
timeout()
{
printf( "alarm went off -- stopping the catch process\n");
fprintf(stderr, "stopping the catch process\n");
unlink(SOCKNAME);
close(s);
exit(6);
}
/*
*
Sample Program : AF_UNIX stream sockets, client process
*
Chapter 6
Using UNIX Domain Stream Sockets
Example Using UNIX Domain Stream Sockets
143

Advertisement

Table of Contents
loading

Table of Contents