HP Rp7410 BSD Sockets Interface Programmer's Guide - Page 140
Example Using UNIX Domain Stream, Sockets
View all HP Rp7410 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 140 highlights
NOTE Using UNIX Domain Stream Sockets Example Using UNIX Domain Stream Sockets Example Using UNIX Domain Stream Sockets These programs are provided as examples only of UNIX Domain stream socket usage and are not Hewlett-Packard supported products. These programming examples demonstrate how to set up and use UNIX Domain stream sockets. These sample programs can be found in the /usr/lib/demos/networking/af_unix directory. The client program is intended to run in conjunction with the server program. This example shows how to create UNIX Domain stream sockets and how to set up address structures for the sockets. In this example the client process sends 2000 bytes of data to the server (five times). The server process can receive data from any other process and will echo the data back to the sender. /* * Sample Program: AF_UNIX stream sockets, server process * * CATCH - RECEIVE DATA FROM THE PITCHER * * Pitch and catch set up a simple unix domain stream socket * client-server connection. The client (pitch) then sends * data to 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 int timeout(); int s; /* server socket */ char buffer[BUFSIZE]; struct bullet { int bytes; int throughput; int magic; } bullet = { 0, 0, 0 }; send_data(fd, buf, buflen) char *buf; { int cc; while (buflen > 0) { 140 Chapter 6