Example Using Unix Domain Stream Sockets - HP Rp3440-4 - 9000 - 0 MB RAM Programmer's Manual

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

Advertisement

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
NOTE
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.
/*
#include <stdio.h>
#include <time.h>
#include <signal.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#define SOCKNAME
#define BUFSIZE
int
int
char buffer[BUFSIZE];
struct bullet {
} bullet = { 0, 0, 0 };
send_data(fd, buf, buflen)
{
140
*
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.
*/
timeout();
s;
int bytes;
int throughput;
int magic;
char *buf;
int cc;
while (buflen > 0) {
"/tmp/p_n_c"
32*1024-1
/* server socket */
Chapter 6

Advertisement

Table of Contents
loading

Table of Contents