HP Rp7410 BSD Sockets Interface Programmer's Guide - Page 144
Pitch - Send Data To The Catcher
View all HP Rp7410 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 144 highlights
Using UNIX Domain Stream Sockets Example Using UNIX Domain Stream Sockets * PITCH - SEND DATA TO THE CATCHER * * Pitch and catch set up a simple unix domain stream socket * client-server connection. The client (pitch) then sends * data to the server (catch), throughput is calculated, and * the result is printed to the client's stdout. */ #include #include #include #include #include #include #include #define SOCKNAME "/tmp/p_n_c" #define BUFSIZE 32*1024-1 char buffer[BUFSIZE]; struct bullet { int bytes; int throughput; int magic; } bullet = { 0, 0, 12345 }; send_data(fd, buf, buflen) char *buf; { int cc; while (buflen > 0) { cc = send(fd, buf, buflen, 0); if (cc == -1) { perror("send"); exit(0); } buf += cc; buflen -= cc; } } recv_data(fd, buf, buflen) char *buf; { int cc; while (buflen > 0) { cc = recv(fd, buf, buflen, 0); if (cc == -1) { perror("recv"); exit(0); } buf += cc; buflen -= cc; } } main( argc, argv) int argc; char *argv[]; { int bufsize, bytes, cc, i, total, pid; float msec; struct timeval tp1, tp2; int s, sendsize, secs, usec; struct timezone tzp; struct sockaddr_un sa; 144 Chapter 6