CS476/576

Assignment #4

Due Midnight, Wednesday  November 8, 2006


Write a C/Sockets program with the following descriptions:

NAME

coreadServer  -   Concurrent Readers Server.

coreadClient  -    Concurrent Readers Client.

 

 

SYNOPSIS

coreadServer        <OutputFile>

coreadClient        <n>    <InputFile>   <RemoteHost>      <Port>

 

DESCRIPTION

 

Ø   The  coreadClient program creates n children processes communicating with the parent using udp sockets.

 

v     Each process  i, i= 1, 2,.., n do the following:

Sleeps a random amount of time T, where T <= n  seconds and when it wakes up it:

·        Reads 128  characters from  InputFile & terminates if there is no more data to read.

·        Use the udp socket to send the PID followed by the data that have been read.

v     The parent reads from its udp socket and sends the received packets to the coreadServer using its tcp socket.

 

Ø      The coreadServer program displays its port number, reads from its tcp socket and produces two files:

§         The OutputFile should be identical to the  InputFile and

§         The PIDCounts  contains the number of  reads performed  by each child process.

 

 

§        

 

 

 

Example:

 

% coreadServer     OutputFile

coreadServer Port#: 61634

running at host: ra.cs.odu.edu (128.82.4.116 )

acceped coreadClient connection

from: 128.82.4.116:61643 (ra.cs.odu.edu)

 

% coreadClient    20   InputFile     ra    61634

 

% cat   PIDReport

 

      4 24408

      5 24392

      5 24398

      5 24403

      5 24411

      6 24397

      6 24401

      6 24405

      6 24415

      6 24417

      7 24396

      7 24407

      7 24409

      7 24414

      8 24393

      8 24394

      8 24406

      8 24416

      9 24399

     10 24395