CS476/576

Assignment #3

Due Midnight, Wednesday   Nov 21, 2012


Write a UNIX/TCP-Socket programs with the following descriptions:

NAME

fodserver forking on-demand server :

      forks  n  processes to echo serve n clients and  then forks at most m on-demand processes to handle additional clients.

 

fodclient  -  a client to  get  echo service from  fodserver.

 

SYNOPSIS

 

         fodserver <n>  <m> <port>

         fodclient   <host>  <port> 

 

 

DESCRIPTION

 

§  The fodclient process:

First it connects to fodserver  at (<host>  <port>) and receives a port number for an echo process and

then connects to that process. After the 2nd connection:

·        Reads a  line from stdin ,  sends it to the echo process.

·        Receives the echoed line and displays it to the stdout.

·        Exits when the user types CTRL-D.

 

§  The fodserver composed of one manager process, n regular & at most m temporary echo processes:

 

The manager process:

·        Creates a server socket, binds it <port> and creates n  regular echo processes.

·        Upon accepting a connection from an  fodclient:

-         If there is a free regular echo process it sends its port to the fodclient.    

-         If there is less than m busy temporary echo processes, it creates a new temporary process and sends its port to the fodclient.

 

Each regular echo process:

·        Creates a server socket,  binds it to any free port,  informs the manager of the assigned port using pipe.

·        Upon accepting a connection from fodclient, it signals the manager that it is busy and then serves the client by echoing  back any received line from the client.

·        When the client closes the connection,  it signals  the manager that it is free and accepts new clients.

 

Each temporary echo process:

·        Creates a server socket,  binds it to any free port,  informs the manager of the assigned port  using shared memory.

·        Upon accepting a connection from fodclient, it informs the manager that it is busy using shared memory and then serves the client by echoing back any received line from the client.

·        When the client closes the connection the process exits and the manager detects its termination via CLD signal.

 

When a user sends an INT signal, the manger kills all existing regular and temporary processes.

 

     See my implementation under: /home/cs476/public_html/fall12/assignments/a3/wahab