Server Design Alternatives



 

 

 

Ø The Client

Ø Iterative Server

Ø Forking on Demand

Ø Pre-Forking

Ø Threading on Demand

Ø Pre-Threading

 

 

 

 

 

 


Ø   The Client

 

v   client.c

 


Example Use:

 
% client  localhost  10123  5   500   4000


Means:

·       Connect to the server running at localhost port 10123.

·       Forks 5 children. 

·       Each child makes 500 TCP connections.

·       Each connection sends the string: "4000\n" and gets 4000 bytes from server.

 

 

 

 

 


Ø   Iterative Server:

 

v  serv00.c  (it uses web_child.c & pr_cpu_time.c)

To test this server, we run only one client as:

% cd /home/cs779/stevens3rd.book/unpv13e/server

% serv00   10123
% client  localhost 10123 1  5000 4000

When client is done, interrupt the server:

^C

and it will print

user time = 0.134386, sys time = 1.58777

 

 

 

 


Ø   Forking on demand: 

 

v serv01.c   (it uses sig_chld_waitpid.c )


% serv01   10123
% client  localhost  10123 5 500 4000

When client is done, interrupt the server

^C

 

 

 

 


Ø   Pre-Forking: 

 

v  serv02.c  (it uses child02.c )

 

% serv02   10123  3  

/* 3 is the number of pre-forks /*
% client  localhost  10123 5 500 4000


When client is done, interrupt the server

^C

 

 

 


Ø   Threading on demand

 

v   serv06.c

% serv06   10123
% client  localhost 10123 5 500 4000

When client is done, interrupt the server

^C

 

 

 

 

 


Ø   Pre-Threading: 

 

v serv07.c  (it uses pthread07.c  )


% serv07   10123 3  

/* 3 is the number of pre-threads /*
% client  localhost  10123 5 500 4000

When client is done, interrupt the server

^C