SlideShare a Scribd company logo
Running Head: IMPLEMENTING THE LIST AND SEARCH
FEATURES IN THE DISTRIBUTED LIBRARY APPLICATION
IMPLEMENTING THE LIST AND SEARCH FEATURES IN
THE DISTRIBUTED LIBRARY APPLICATION 11
Implementing the List and Search Features In the Distributed
Library Application
Name of Student
Name of Institution
Date of submission
Implementing the List and Search Features In the Distributed
Library Application
Abstract
In the world of programming, Perl and C are the common set of
computer programs used to execute computer commands. Perl
scripts are so popular, particularly for programs that manages
huge quantities of text like the indexers. Perl scripts are very
easy and at times can be very difficult subject to the intended
use. A good example is that they can be developed to perform
particular tasks like deleting or renaming of files. In the
Implementing the List and Search Features in the Distributed
Library Application, a client can be used to run distributed
library application at the library for the purpose of serving
books. Once installed and running, upon waiting for requests
from peers concerning books requested for the client, the
program writes a sequence of codes that are necessary for
performing the required steps
The below are the modifications that are vital at the client end;
Client script;
#!/usr/bin/Perl
use IO::Socket::INET;
$socket = new IO::Socket::INET (
PeerHost => '122.0.0.1',
PeerPort => '30000',
Proto => 'tcp',
) or die "Oops : $!n";
print "Waiting for requests.n";
#Port number, login ID and password.
$serverinfo = <$socket>;
print " Port number ,login ID and password: $serverinfo n";
# Login ID and password information.
$clientinfo = "... Ok, this is client speaking ...";
print $socket "$clientdata n";
$socket->terminate{};
On registration,
#!/usr/bin/Perl
open {REGISTRATION, "registration"}
die "Can't open registration: $!n";
· while {$line = <login ID, password, and port number(3302)>}
[
{$menu, $registration} = split{/ /, $line};
$registration[$menu ] .= $registration. " ";
]
Server script;
#!/usr/bin/perl
use IO::Socket::INET;
$socket = new IO::Socket::INET {
LocalHost => '122.0.0.1',
LocalPort => '30000',
Proto => 'tcp',
Listen => 10,
Reuse => 1
} or die "Oops: $! n";
print "Server is up and running ... n";
while {1} [
$clientsocket = $socket->registered{};
print " **** Recent Client Registered **** n ";
# Port number, login ID and password.
$serverinfo = "This is server speaking ...";
print $clientsocket "$serverinfo n";
# Login ID and password information.
$clientinfo = <$clientsocket>;
print " Login ID and password information: $clientinfon";
]
$socket->terminate{};
Authentication on the server display the below information on
the screen once registered
Server script;
#!/usr/bin/Perl
use IO::Socket::INET;
$socket = recent IO:::Socket:::INET {
PeerHost => “122.0.0.1”,
PeerPort => “30000”,
Proto => “tcp”,
} or fail ‘Oops : $!n’;
print ‘Connected to the server.n’;
# Authenticated.
$server-info = ($socket);
print ‘authenticated: $server-info n’;
# Submit.
$client-info = ‘...client talking ...’;
print $socket ‘$client-info n’;
$socket->lock{};
Output: server.pl
Server is up and running ...
**** Client Authenticated ****
Ok: ... client talking...
Output: client.pl
Connected to the server
Authenticated: …server talking...
Connected to the server
Authenticated: …server talking...
On receiving a reply from the server, the client arbitrarily picks
another client and contacts it with a time-of-day request
Client script;
#!/usr/bin/perl
use IO::Socket::INET;
$socket = new IO::Socket::INET {
LocalHost => '122.0.0.1',
LocalPort => '30000',
Proto => 'tcp',
Listen => 10,
Reuse => 1
} or die "Oops: $! n";
print "Server is up and running ... n";
while {1} [
$clientsocket = $socket->registered{};
print " **** Recent Client Added **** n ";
# Port number, login ID and password.
$serverinfo = "This is server speaking ...";
print $clientsocket "$serverinfo n";
# Login ID and password information.
$clientinfo = <$clientsocket>;
print " Login ID and password information: $clientinfon";
]
$socket->terminate{};
A copy of your client and server programs implementing the
distributed library application.
The server initiates the thread and on the screen, the following
is seen;
Server.pl
#!/usr/bin/Perl
use IO:::Socket:::INET;
$socket = recent IO:::Socket:::INET {
LocalHost =>::122.0.0.1”,
LocalPort => “30000”,
Proto => “tcp”,
Snoop=> 15,
Salvage => 1
} or fail ‘Oops: $! n’;
print ‘Server is up and running ... n’;
while {1} [
$clientsocket = $socket->register{};
print ‘ *** Recent Client Connected *** n ‘;
# Port number, Login ID and Password
$server-info = ‘…server talking ...’;
print $clientsocket ‘$server-info n’;
# registration details
$client-info = ($clientsocket);
print ‘registration details: $client-infon’;
}
$socket->lock{};
Client.pl
#!/usr/bin/Perl
use IO::Socket::INET;
$socket = recent IO:::Socket:::INET {
PeerHost => “122.0.0.1”,
PeerPort => “30000”,
Proto => “tcp”,
} or fail ‘Oops : $!n’;
print ‘Connected to the server.n’;
# Registered.
$server-info = ($socket);
print ‘registered: $server-info n’;
# Submit.
$client-info = ‘...client talking ...’;
print $socket ‘$client-info n’;
$socket->lock{};
Describe the method for invoking your programs
Server script;
$local = IO:::Socket:::INET->new{
Proto => 'tcp'
LocalAddress => 'localhost:8090',
Reuse => 1
} or fail "$!";
$local->listen{};
$local->autoflush{1};
print "At your service. Waiting...n";
my $address;
while {$address = $local->accept} } [
print "Linked from: ", $address->peerhost{};
print " Port: ", $address->peerport{}, "n";
my $result;
while {<$address>} [
last if m/^end/gi;
print "Received: $_";
print $address $_;
$result += $_;
]
chomp;
if {m/^end/gi} [
my $send = "result=$result";
print $address "$sendn";
print "Result: $sendn";
]
print "Locked connectionn";
lock $address;
print "At your service. Waiting...n";
]
Client script;
$remote = IO:::Socket:::INET->new{
Proto => 'tcp',
PeerAddress=> 'localhost',
PeerPort=> "8090",
Reuse => 1,
} or fail "$!";
print "Linked to ", $remote->peerhost,
" on port: ", $remote->peerport, "n";
$remote->autoflush{1};
while {<>} [
print $remote $_;
last if m/^end/gi;
my $line = <$remote>;
if {$line ne $_} [
print "Error in sending outputn";
exit;
]
]
my $res = <$remote>;
$res =~ m/result={d*}/gi;
print "Result: $1n";
print "Client terminatedn";
lock $remote
Client and server window screenshots to validate the
implementation.
Server window screenshot
References
Feddema, H. B. (2004). Expert one-on-one Microsoft Access
application development.
Indianapolis, IN: Wiley Pub..
Sugumaran, V. (2007). Application of agents and intelligent
information technologies. Hershey,
PA: Idea Group Pub..
Running Head: HANDLING CONCURRENT CLIENTS
HANDLING CONCURRENT CLIENTS 6
HANDLING CONCURRENT CLIENTS
Student’s Name
Institution
Date of Submission
HANDLING CONCURRENT CLIENTS
Discuss how you will design the server in the given situation to
handle multiple clients arbitrarily entering and leaving the
system?
Once a one or single client server has been established, it
becomes obvious that this server can only serve one client at a
time. In order to have a server that can handle more than a
single client at a time, a multiple or multi – client server must
be created to perform this operation. Here are the steps followed
in creating a multi – client server and its discussion.
main = withSocketsDo $ do
sock <- listenOn {PortNumber {fromIntegral port}}
printf "Listening on port %dn" port
forever $ do
{handle, host, port} <- accept sock
printf "Accepted connection from %s: %sn" host
{show port}
forkFinally {talk handle} {_ -> hClose handle}
port :: Int
port = 44444
The first thing that the programmer does is to create a listening
port 4444 through the network socket. Once the listening port
has been created, the programmer goes ahead to insert a loop
that will accept all the possible connections that are made by
the client. The loop then waits for any possible connection that
might be made by any client. Prior to any connection, the accept
command from the program remains blocked until the moment
the client will send a request. After the request has been
initiated, a handle is created that allows for communication
between the client and the server where details about the client
are shared. The sharing of the client’s details enables a link to
be created between the server and the client in the form of a
binding, host to the client and port to the server. This binding
allows the client to log in to the server. Once the binding has
been made, the programmer creates a new thread that is
purposely made to handle the client’s requests. This becomes
folkfinally of the new thread formed. The interaction between
the client and the server henceforth is assigned to talk where the
handle returns after a connection call is accepted.
Describe your server design in detail.
There are four possible designs that allows for ease in handling
concurrent clients. Among the four, my choice of design is
design four that uses the STM. STM is a design that has seen
improvement from design three that uses broadcast chan. In this
design, the channel for communication between the client and
the server is avoided by storing in TVar all factors that are at
the moment.
Justification of STM Design
In STM the use of TVar reflects this on the screen:
newtype State = State [ currentFactor :: TVar Int ]
The reason for using STM design has been contributed by its
ability to block changes until something happens. Due to this it
spares the server the need to send messages overtly when a
change is made. In order to understand this, let’s follow the
explanation below:
When a client makes a sequence of events (N) to the server, the
following happens;
· The Handle receives N commands from the client and sends it
to the TChan thread of the server.
· Once received, the server makes a command on its TChan and
starts modifying the current factors in TVar.
· All the respective threads made acknowledge the changes
observed in TVar and forward the changed value back to the
client.
A simple diagram of STM Design
TVar
Server
TChan
Thread Received
Network Socket
An alternative language to be used to implement this design
would be C. Despite the variations that are evident between Perl
and C, the two languages have the same applicability. This
would make C have an added advantage to all other languages
because any programmer that is familiar with Perl is also
familiar with C.
Implementing STM Design
STM is the simplest architecture to be implemented; here is how
it can be done;
server2.hs
main = withSocketsDo $ do
sock <- listenOn {PortNumber {fromIntegral port}}
printf "Listening on port %dn" port
factor <- atomically $ newTVar 2
forever $ do
{handle, host, port} <- accept sock
printf "Accepted connection from %s: %sn" host
{show port}
forkFinally {talk handle factor} {_ -> hClose
handle}
port :: Int
port = 44444
The new connection made to the client from the talk function is
then set:
talk :: Handle -> TVar Integer -> IO {}
talk h factor = do
hSetBuffering h LineBuffering
c <- atomically newTChan
race {server h factor c} {receive h c}
return {}
Once received, the repeated function from the Handle writes the
following tothe TChan:
receive :: Handle -> TChan String -> IO {}
receive h c = forever $ do
line <- hGetLine h
atomically $ writeTChan c line
At the server, the following takes place:
server :: Handle -> TVar Integer -> TChan String ->
IO {}
server h factor c = do
f <- atomically $ readTVar factor
hPrintf h "Current factor: %dn" f
loop f
where
loop f = do
action <- atomically $ do
f' <- readTVar factor
if {f /= f'}
then return {newfactor f'}
also do
l <- readTChan c
return {command f l}
action
newfactor f = do
hPrintf h "new factor: %dn" f
loop f
command f s
= case s of
"end" ->
hPutStrLn h {"Thank you for using the " ++
"Perl doubling service."}
'*':s -> do
atomically $ writeTVar factor [read s :: Integer]
loop f
line -> do
hPutStrLn h {show {f * {read line :: Integer}}}
loop f
There is no challenging task to in implementing STM design
since it’s the simplest design compared to the other three. This
is made possible by its ability to block any changes before any
command takes place.
Running Head: HANDLING CONCURRENT CLIENTS
HANDLING CONCURRENT CLIENTS 6
HANDLING CONCURRENT CLIENTS
Student’s Name
Institution
Date of Submission
HANDLING CONCURRENT CLIENTS
Discuss how you will design the server in the given situation to
handle multiple clients arbitrarily entering and leaving the
system?
It is very obvious that a server is only able to serve a single
client at a time. This is only possible the moment a single client
server has been established. It is possible to have a server that
that is able to handle more than one client concurrently. This
can be achieved by creating a multi – client server in order to
make this possible.
Below are the steps that need to be followed in designing a
server that will be able to handle multiple clients
main = withSocketsDo $ do
sock <- listenOn {PortNumber {fromIntegral port}}
printf "Listening on port %dn" port
forever $ do
{handle, host, port} <- accept sock
printf "Accepted connection from %s: %sn" host
{show port}
forkFinally {talk handle} {_ -> hClose handle}
port :: Int
port = 44444
Creating a listening port 4444 through the network socket is the
very first thing the programmer performs. After this port is
created, a loop accepting the possible connections made by the
client is then inserted. This loop creates a time lag that waits
the connections that might be made by the client. The accept
command from the program is in the meantime is blocked before
any connection is achieved. The blockage continues till the
client sends a request.
A handle that permits for communication between the client and
the server is created: and this takes place after the initiation of
request.it is here where the client’s information sharing takes
place. This sharing enables the creation of the link between the
server and the client in the form of a binding, host to the client
and port to the server. This binding allows the client to log in to
the server. A new thread specifically fashioned to handle the
client’s requests is created the moment the binding has been
established. This becomes folkfinally of the new thread formed.
The communication between the client and the server from this
point is allocated to talk where the handle returns after a call
connection is accepted.
Describe your server design in detail.
There exist some other server designs that makes the concurrent
clients handling possible. This all depends with the design used
as some are not easy to implement. The best server design
choice that works best for me is the STM design. Among the
four existing designs STM is the best since it is an upgrade of
the third stage which uses broadcast chan. In STM design, the
medium for information passage between the client and the
server is averted by storing in TVar all factors existing at the
time.
Justification of STM Design
In this design the use of TVar displays the following on the
screen:
newtype State = State [ currentFactor :: TVar Int ]
The STM ability to block changes until something takes place is
the primary reason for its choice. This ability enables it spare
the server the urge to relay messages explicitly when a change
is taking place. This is further explained below
When a client makes a sequence of events (N) to the server, the
following happens;
· The Handle receives N commands from the client and sends it
to the TChan thread of the server.
· Once received, the server makes a command on its TChan and
starts modifying the current factors in TVar.
· All the respective threads made acknowledge the changes
observed in TVar and forward the changed value back to the
client.
A simple diagram of STM Design
TVar
Server
TChan
Thread Received
Network Socket
An alternative language to be used to implement this design
would be C. Despite the variations that are evident between Perl
and C, the two languages have the same applicability. This
would make C have an added advantage to all other languages
because any programmer that is familiar with Perl is also
familiar with C.
Implementing STM Design
STM is the simplest architecture to be implemented; here is how
it can be done;
server2.hs
main = withSocketsDo $ do
sock <- listenOn {PortNumber {fromIntegral port}}
printf "Listening on port %dn" port
factor <- atomically $ newTVar 2
forever $ do
{handle, host, port} <- accept sock
printf "Accepted connection from %s: %sn" host
{show port}
forkFinally {talk handle factor} {_ -> hClose
handle}
port :: Int
port = 44444
The new connection made to the client from the talk function is
then set:
talk :: Handle -> TVar Integer -> IO {}
talk h factor = do
hSetBuffering h LineBuffering
c <- atomically newTChan
race {server h factor c} {receive h c}
return {}
Once received, the repeated function from the Handle writes the
following tothe TChan:
receive :: Handle -> TChan String -> IO {}
receive h c = forever $ do
line <- hGetLine h
atomically $ writeTChan c line
At the server, the following takes place:
server :: Handle -> TVar Integer -> TChan String ->
IO {}
server h factor c = do
f <- atomically $ readTVar factor
hPrintf h "Current factor: %dn" f
loop f
where
loop f = do
action <- atomically $ do
f' <- readTVar factor
if {f /= f'}
then return {newfactor f'}
also do
l <- readTChan c
return {command f l}
action
newfactor f = do
hPrintf h "new factor: %dn" f
loop f
command f s
= case s of
"end" ->
hPutStrLn h {"Thank you for using the " ++
"Perl doubling service."}
'*':s -> do
atomically $ writeTVar factor [read s :: Integer]
loop f
line -> do
hPutStrLn h {show {f * {read line :: Integer}}}
loop f
There is no challenging task to in implementing STM design
since it’s the simplest design compared to the other three. This
is made possible by its ability to block any changes before any
command takes place.

More Related Content

Similar to Running Head IMPLEMENTING THE LIST AND SEARCH FEATURES IN THE DIS.docx

Please look at the attach See.doc. I am getting this error all th.docx
Please look at the attach See.doc. I am getting this error all th.docxPlease look at the attach See.doc. I am getting this error all th.docx
Please look at the attach See.doc. I am getting this error all th.docx
randymartin91030
 
Network programming
Network programmingNetwork programming
Net Programming.ppt
Net Programming.pptNet Programming.ppt
Net Programming.ppt
EloAcubaOgardo
 
Simple callcenter platform with PHP
Simple callcenter platform with PHPSimple callcenter platform with PHP
Simple callcenter platform with PHP
Morten Amundsen
 
Network Prog.ppt
Network Prog.pptNetwork Prog.ppt
Network Prog.ppt
EloOgardo
 
A.java
A.javaA.java
FMS Administration Seminar
FMS Administration SeminarFMS Administration Seminar
FMS Administration Seminar
Yoss Cohen
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...
Tom Croucher
 
Remote Procedure Call
Remote Procedure CallRemote Procedure Call
Remote Procedure Call
Nadia Nahar
 
Web Server and how we can design app in C#
Web Server and how we can design app  in C#Web Server and how we can design app  in C#
Web Server and how we can design app in C#
caohansnnuedu
 
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmenMCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
VannaSchrader3
 
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docxMCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
alfredacavx97
 
Network Programming-Python-13-8-2023.pptx
Network Programming-Python-13-8-2023.pptxNetwork Programming-Python-13-8-2023.pptx
Network Programming-Python-13-8-2023.pptx
ssuser23035c
 
Networking Java Socket Programming
Networking Java Socket ProgrammingNetworking Java Socket Programming
Networking Java Socket Programming
Mousmi Pawar
 
Use perl creating web services with xml rpc
Use perl creating web services with xml rpcUse perl creating web services with xml rpc
Use perl creating web services with xml rpc
Johnny Pork
 
Project Assignment 2 Building a Multi-Threaded Web ServerThis pro.docx
Project Assignment 2 Building a Multi-Threaded Web ServerThis pro.docxProject Assignment 2 Building a Multi-Threaded Web ServerThis pro.docx
Project Assignment 2 Building a Multi-Threaded Web ServerThis pro.docx
kacie8xcheco
 
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Masahiro Nagano
 
Exploring Async PHP (SF Live Berlin 2019)
Exploring Async PHP (SF Live Berlin 2019)Exploring Async PHP (SF Live Berlin 2019)
Exploring Async PHP (SF Live Berlin 2019)
dantleech
 
Sockets
SocketsSockets
Sockets
sivindia
 
How a network connection is created A network connection is initi.pdf
How a network connection is created A network connection is initi.pdfHow a network connection is created A network connection is initi.pdf
How a network connection is created A network connection is initi.pdf
arccreation001
 

Similar to Running Head IMPLEMENTING THE LIST AND SEARCH FEATURES IN THE DIS.docx (20)

Please look at the attach See.doc. I am getting this error all th.docx
Please look at the attach See.doc. I am getting this error all th.docxPlease look at the attach See.doc. I am getting this error all th.docx
Please look at the attach See.doc. I am getting this error all th.docx
 
Network programming
Network programmingNetwork programming
Network programming
 
Net Programming.ppt
Net Programming.pptNet Programming.ppt
Net Programming.ppt
 
Simple callcenter platform with PHP
Simple callcenter platform with PHPSimple callcenter platform with PHP
Simple callcenter platform with PHP
 
Network Prog.ppt
Network Prog.pptNetwork Prog.ppt
Network Prog.ppt
 
A.java
A.javaA.java
A.java
 
FMS Administration Seminar
FMS Administration SeminarFMS Administration Seminar
FMS Administration Seminar
 
A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...A language for the Internet: Why JavaScript and Node.js is right for Internet...
A language for the Internet: Why JavaScript and Node.js is right for Internet...
 
Remote Procedure Call
Remote Procedure CallRemote Procedure Call
Remote Procedure Call
 
Web Server and how we can design app in C#
Web Server and how we can design app  in C#Web Server and how we can design app  in C#
Web Server and how we can design app in C#
 
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmenMCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen
 
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docxMCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
MCIS 6163 Assignment 1MCIS 6163 Assignment 1.pdfAssignmen.docx
 
Network Programming-Python-13-8-2023.pptx
Network Programming-Python-13-8-2023.pptxNetwork Programming-Python-13-8-2023.pptx
Network Programming-Python-13-8-2023.pptx
 
Networking Java Socket Programming
Networking Java Socket ProgrammingNetworking Java Socket Programming
Networking Java Socket Programming
 
Use perl creating web services with xml rpc
Use perl creating web services with xml rpcUse perl creating web services with xml rpc
Use perl creating web services with xml rpc
 
Project Assignment 2 Building a Multi-Threaded Web ServerThis pro.docx
Project Assignment 2 Building a Multi-Threaded Web ServerThis pro.docxProject Assignment 2 Building a Multi-Threaded Web ServerThis pro.docx
Project Assignment 2 Building a Multi-Threaded Web ServerThis pro.docx
 
Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015Rhebok, High Performance Rack Handler / Rubykaigi 2015
Rhebok, High Performance Rack Handler / Rubykaigi 2015
 
Exploring Async PHP (SF Live Berlin 2019)
Exploring Async PHP (SF Live Berlin 2019)Exploring Async PHP (SF Live Berlin 2019)
Exploring Async PHP (SF Live Berlin 2019)
 
Sockets
SocketsSockets
Sockets
 
How a network connection is created A network connection is initi.pdf
How a network connection is created A network connection is initi.pdfHow a network connection is created A network connection is initi.pdf
How a network connection is created A network connection is initi.pdf
 

More from cowinhelen

Case Study 1 Applying Theory to PracticeSocial scientists hav.docx
Case Study 1 Applying Theory to PracticeSocial scientists hav.docxCase Study 1 Applying Theory to PracticeSocial scientists hav.docx
Case Study 1 Applying Theory to PracticeSocial scientists hav.docx
cowinhelen
 
Case Study - Option 3 BarbaraBarbara is a 22 year old woman who h.docx
Case Study - Option 3 BarbaraBarbara is a 22 year old woman who h.docxCase Study - Option 3 BarbaraBarbara is a 22 year old woman who h.docx
Case Study - Option 3 BarbaraBarbara is a 22 year old woman who h.docx
cowinhelen
 
Case Study - Cyberterrorism—A New RealityWhen hackers claiming .docx
Case Study - Cyberterrorism—A New RealityWhen hackers claiming .docxCase Study - Cyberterrorism—A New RealityWhen hackers claiming .docx
Case Study - Cyberterrorism—A New RealityWhen hackers claiming .docx
cowinhelen
 
Case Study - APA paper with min 4 page content Review the Blai.docx
Case Study - APA paper with min 4 page content Review the Blai.docxCase Study - APA paper with min 4 page content Review the Blai.docx
Case Study - APA paper with min 4 page content Review the Blai.docx
cowinhelen
 
Case Study - Global Mobile Corporation Damn it, .docx
Case Study - Global Mobile Corporation      Damn it, .docxCase Study - Global Mobile Corporation      Damn it, .docx
Case Study - Global Mobile Corporation Damn it, .docx
cowinhelen
 
Case Study #3Apple Suppliers & Labor PracticesWith its h.docx
Case Study #3Apple Suppliers & Labor PracticesWith its h.docxCase Study #3Apple Suppliers & Labor PracticesWith its h.docx
Case Study #3Apple Suppliers & Labor PracticesWith its h.docx
cowinhelen
 
CASE STUDY (Individual) Scotland  In terms of its physical l.docx
CASE STUDY (Individual) Scotland  In terms of its physical l.docxCASE STUDY (Individual) Scotland  In terms of its physical l.docx
CASE STUDY (Individual) Scotland  In terms of its physical l.docx
cowinhelen
 
Case Study #2 T.D. enjoys caring for the children and young peop.docx
Case Study #2 T.D. enjoys caring for the children and young peop.docxCase Study #2 T.D. enjoys caring for the children and young peop.docx
Case Study #2 T.D. enjoys caring for the children and young peop.docx
cowinhelen
 
CASE STUDY #2 Chief Complaint I have pain in my belly”.docx
CASE STUDY #2 Chief Complaint I have pain in my belly”.docxCASE STUDY #2 Chief Complaint I have pain in my belly”.docx
CASE STUDY #2 Chief Complaint I have pain in my belly”.docx
cowinhelen
 
Case Study #1Jennifer is a 29-year-old administrative assistan.docx
Case Study #1Jennifer is a 29-year-old administrative assistan.docxCase Study #1Jennifer is a 29-year-old administrative assistan.docx
Case Study #1Jennifer is a 29-year-old administrative assistan.docx
cowinhelen
 
Case Study # 2 –Danny’s Unhappy DutyEmployee ProfilesCaro.docx
Case Study # 2 –Danny’s Unhappy DutyEmployee ProfilesCaro.docxCase Study # 2 –Danny’s Unhappy DutyEmployee ProfilesCaro.docx
Case Study # 2 –Danny’s Unhappy DutyEmployee ProfilesCaro.docx
cowinhelen
 
Case Study – Multicultural ParadeRead the Case below, and answe.docx
Case Study  – Multicultural ParadeRead the Case below, and answe.docxCase Study  – Multicultural ParadeRead the Case below, and answe.docx
Case Study – Multicultural ParadeRead the Case below, and answe.docx
cowinhelen
 
Case Study   THE INVISIBLE SPONSOR1BackgroundSome execut.docx
Case Study    THE INVISIBLE SPONSOR1BackgroundSome execut.docxCase Study    THE INVISIBLE SPONSOR1BackgroundSome execut.docx
Case Study   THE INVISIBLE SPONSOR1BackgroundSome execut.docx
cowinhelen
 
CASE STUDY Experiential training encourages changes in work beha.docx
CASE STUDY  Experiential training encourages changes in work beha.docxCASE STUDY  Experiential training encourages changes in work beha.docx
CASE STUDY Experiential training encourages changes in work beha.docx
cowinhelen
 
Case Study Hereditary AngioedemaAll responses must be in your .docx
Case Study  Hereditary AngioedemaAll responses must be in your .docxCase Study  Hereditary AngioedemaAll responses must be in your .docx
Case Study Hereditary AngioedemaAll responses must be in your .docx
cowinhelen
 
case studieson Gentrification and Displacement in the Sa.docx
case studieson Gentrification and Displacement in the Sa.docxcase studieson Gentrification and Displacement in the Sa.docx
case studieson Gentrification and Displacement in the Sa.docx
cowinhelen
 
Case Studt on KFC Introduction1) Identify the type of .docx
Case Studt on KFC Introduction1) Identify the type of .docxCase Studt on KFC Introduction1) Identify the type of .docx
Case Studt on KFC Introduction1) Identify the type of .docx
cowinhelen
 
Case Study Crocs Revolutionizing an Industry’s Supply Chain .docx
Case Study  Crocs Revolutionizing an Industry’s Supply Chain .docxCase Study  Crocs Revolutionizing an Industry’s Supply Chain .docx
Case Study Crocs Revolutionizing an Industry’s Supply Chain .docx
cowinhelen
 
Case Studies Student must complete 5 case studies as instructed.docx
Case Studies Student must complete 5 case studies as instructed.docxCase Studies Student must complete 5 case studies as instructed.docx
Case Studies Student must complete 5 case studies as instructed.docx
cowinhelen
 
Case Studies in Telehealth AdoptionThe mission of The Comm.docx
Case Studies in Telehealth AdoptionThe mission of The Comm.docxCase Studies in Telehealth AdoptionThe mission of The Comm.docx
Case Studies in Telehealth AdoptionThe mission of The Comm.docx
cowinhelen
 

More from cowinhelen (20)

Case Study 1 Applying Theory to PracticeSocial scientists hav.docx
Case Study 1 Applying Theory to PracticeSocial scientists hav.docxCase Study 1 Applying Theory to PracticeSocial scientists hav.docx
Case Study 1 Applying Theory to PracticeSocial scientists hav.docx
 
Case Study - Option 3 BarbaraBarbara is a 22 year old woman who h.docx
Case Study - Option 3 BarbaraBarbara is a 22 year old woman who h.docxCase Study - Option 3 BarbaraBarbara is a 22 year old woman who h.docx
Case Study - Option 3 BarbaraBarbara is a 22 year old woman who h.docx
 
Case Study - Cyberterrorism—A New RealityWhen hackers claiming .docx
Case Study - Cyberterrorism—A New RealityWhen hackers claiming .docxCase Study - Cyberterrorism—A New RealityWhen hackers claiming .docx
Case Study - Cyberterrorism—A New RealityWhen hackers claiming .docx
 
Case Study - APA paper with min 4 page content Review the Blai.docx
Case Study - APA paper with min 4 page content Review the Blai.docxCase Study - APA paper with min 4 page content Review the Blai.docx
Case Study - APA paper with min 4 page content Review the Blai.docx
 
Case Study - Global Mobile Corporation Damn it, .docx
Case Study - Global Mobile Corporation      Damn it, .docxCase Study - Global Mobile Corporation      Damn it, .docx
Case Study - Global Mobile Corporation Damn it, .docx
 
Case Study #3Apple Suppliers & Labor PracticesWith its h.docx
Case Study #3Apple Suppliers & Labor PracticesWith its h.docxCase Study #3Apple Suppliers & Labor PracticesWith its h.docx
Case Study #3Apple Suppliers & Labor PracticesWith its h.docx
 
CASE STUDY (Individual) Scotland  In terms of its physical l.docx
CASE STUDY (Individual) Scotland  In terms of its physical l.docxCASE STUDY (Individual) Scotland  In terms of its physical l.docx
CASE STUDY (Individual) Scotland  In terms of its physical l.docx
 
Case Study #2 T.D. enjoys caring for the children and young peop.docx
Case Study #2 T.D. enjoys caring for the children and young peop.docxCase Study #2 T.D. enjoys caring for the children and young peop.docx
Case Study #2 T.D. enjoys caring for the children and young peop.docx
 
CASE STUDY #2 Chief Complaint I have pain in my belly”.docx
CASE STUDY #2 Chief Complaint I have pain in my belly”.docxCASE STUDY #2 Chief Complaint I have pain in my belly”.docx
CASE STUDY #2 Chief Complaint I have pain in my belly”.docx
 
Case Study #1Jennifer is a 29-year-old administrative assistan.docx
Case Study #1Jennifer is a 29-year-old administrative assistan.docxCase Study #1Jennifer is a 29-year-old administrative assistan.docx
Case Study #1Jennifer is a 29-year-old administrative assistan.docx
 
Case Study # 2 –Danny’s Unhappy DutyEmployee ProfilesCaro.docx
Case Study # 2 –Danny’s Unhappy DutyEmployee ProfilesCaro.docxCase Study # 2 –Danny’s Unhappy DutyEmployee ProfilesCaro.docx
Case Study # 2 –Danny’s Unhappy DutyEmployee ProfilesCaro.docx
 
Case Study – Multicultural ParadeRead the Case below, and answe.docx
Case Study  – Multicultural ParadeRead the Case below, and answe.docxCase Study  – Multicultural ParadeRead the Case below, and answe.docx
Case Study – Multicultural ParadeRead the Case below, and answe.docx
 
Case Study   THE INVISIBLE SPONSOR1BackgroundSome execut.docx
Case Study    THE INVISIBLE SPONSOR1BackgroundSome execut.docxCase Study    THE INVISIBLE SPONSOR1BackgroundSome execut.docx
Case Study   THE INVISIBLE SPONSOR1BackgroundSome execut.docx
 
CASE STUDY Experiential training encourages changes in work beha.docx
CASE STUDY  Experiential training encourages changes in work beha.docxCASE STUDY  Experiential training encourages changes in work beha.docx
CASE STUDY Experiential training encourages changes in work beha.docx
 
Case Study Hereditary AngioedemaAll responses must be in your .docx
Case Study  Hereditary AngioedemaAll responses must be in your .docxCase Study  Hereditary AngioedemaAll responses must be in your .docx
Case Study Hereditary AngioedemaAll responses must be in your .docx
 
case studieson Gentrification and Displacement in the Sa.docx
case studieson Gentrification and Displacement in the Sa.docxcase studieson Gentrification and Displacement in the Sa.docx
case studieson Gentrification and Displacement in the Sa.docx
 
Case Studt on KFC Introduction1) Identify the type of .docx
Case Studt on KFC Introduction1) Identify the type of .docxCase Studt on KFC Introduction1) Identify the type of .docx
Case Studt on KFC Introduction1) Identify the type of .docx
 
Case Study Crocs Revolutionizing an Industry’s Supply Chain .docx
Case Study  Crocs Revolutionizing an Industry’s Supply Chain .docxCase Study  Crocs Revolutionizing an Industry’s Supply Chain .docx
Case Study Crocs Revolutionizing an Industry’s Supply Chain .docx
 
Case Studies Student must complete 5 case studies as instructed.docx
Case Studies Student must complete 5 case studies as instructed.docxCase Studies Student must complete 5 case studies as instructed.docx
Case Studies Student must complete 5 case studies as instructed.docx
 
Case Studies in Telehealth AdoptionThe mission of The Comm.docx
Case Studies in Telehealth AdoptionThe mission of The Comm.docxCase Studies in Telehealth AdoptionThe mission of The Comm.docx
Case Studies in Telehealth AdoptionThe mission of The Comm.docx
 

Recently uploaded

Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
TechSoup
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
adhitya5119
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
amberjdewit93
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
taiba qazi
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
Celine George
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
ak6969907
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
Priyankaranawat4
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
thanhdowork
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
Nguyen Thanh Tu Collection
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
Bisnar Chase Personal Injury Attorneys
 

Recently uploaded (20)

Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat  Leveraging AI for Diversity, Equity, and InclusionExecutive Directors Chat  Leveraging AI for Diversity, Equity, and Inclusion
Executive Directors Chat Leveraging AI for Diversity, Equity, and Inclusion
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Main Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docxMain Java[All of the Base Concepts}.docx
Main Java[All of the Base Concepts}.docx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Digital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental DesignDigital Artefact 1 - Tiny Home Environmental Design
Digital Artefact 1 - Tiny Home Environmental Design
 
DRUGS AND ITS classification slide share
DRUGS AND ITS classification slide shareDRUGS AND ITS classification slide share
DRUGS AND ITS classification slide share
 
How to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP ModuleHow to Add Chatter in the odoo 17 ERP Module
How to Add Chatter in the odoo 17 ERP Module
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024World environment day ppt For 5 June 2024
World environment day ppt For 5 June 2024
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
clinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdfclinical examination of hip joint (1).pdf
clinical examination of hip joint (1).pdf
 
Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.Types of Herbal Cosmetics its standardization.
Types of Herbal Cosmetics its standardization.
 
A Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptxA Survey of Techniques for Maximizing LLM Performance.pptx
A Survey of Techniques for Maximizing LLM Performance.pptx
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 CẢ NĂM - GLOBAL SUCCESS - NĂM HỌC 2023-2024 (CÓ FI...
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
Top five deadliest dog breeds in America
Top five deadliest dog breeds in AmericaTop five deadliest dog breeds in America
Top five deadliest dog breeds in America
 

Running Head IMPLEMENTING THE LIST AND SEARCH FEATURES IN THE DIS.docx

  • 1. Running Head: IMPLEMENTING THE LIST AND SEARCH FEATURES IN THE DISTRIBUTED LIBRARY APPLICATION IMPLEMENTING THE LIST AND SEARCH FEATURES IN THE DISTRIBUTED LIBRARY APPLICATION 11 Implementing the List and Search Features In the Distributed Library Application Name of Student Name of Institution Date of submission Implementing the List and Search Features In the Distributed Library Application Abstract In the world of programming, Perl and C are the common set of computer programs used to execute computer commands. Perl scripts are so popular, particularly for programs that manages huge quantities of text like the indexers. Perl scripts are very easy and at times can be very difficult subject to the intended use. A good example is that they can be developed to perform particular tasks like deleting or renaming of files. In the Implementing the List and Search Features in the Distributed
  • 2. Library Application, a client can be used to run distributed library application at the library for the purpose of serving books. Once installed and running, upon waiting for requests from peers concerning books requested for the client, the program writes a sequence of codes that are necessary for performing the required steps The below are the modifications that are vital at the client end; Client script; #!/usr/bin/Perl use IO::Socket::INET; $socket = new IO::Socket::INET ( PeerHost => '122.0.0.1', PeerPort => '30000', Proto => 'tcp', ) or die "Oops : $!n"; print "Waiting for requests.n"; #Port number, login ID and password. $serverinfo = <$socket>; print " Port number ,login ID and password: $serverinfo n"; # Login ID and password information. $clientinfo = "... Ok, this is client speaking ..."; print $socket "$clientdata n"; $socket->terminate{}; On registration, #!/usr/bin/Perl open {REGISTRATION, "registration"}
  • 3. die "Can't open registration: $!n"; · while {$line = <login ID, password, and port number(3302)>} [ {$menu, $registration} = split{/ /, $line}; $registration[$menu ] .= $registration. " "; ] Server script; #!/usr/bin/perl use IO::Socket::INET; $socket = new IO::Socket::INET { LocalHost => '122.0.0.1', LocalPort => '30000', Proto => 'tcp', Listen => 10, Reuse => 1 } or die "Oops: $! n"; print "Server is up and running ... n"; while {1} [ $clientsocket = $socket->registered{}; print " **** Recent Client Registered **** n "; # Port number, login ID and password. $serverinfo = "This is server speaking ..."; print $clientsocket "$serverinfo n"; # Login ID and password information. $clientinfo = <$clientsocket>; print " Login ID and password information: $clientinfon"; ] $socket->terminate{};
  • 4. Authentication on the server display the below information on the screen once registered Server script; #!/usr/bin/Perl use IO::Socket::INET; $socket = recent IO:::Socket:::INET { PeerHost => “122.0.0.1”, PeerPort => “30000”, Proto => “tcp”, } or fail ‘Oops : $!n’; print ‘Connected to the server.n’; # Authenticated. $server-info = ($socket); print ‘authenticated: $server-info n’; # Submit. $client-info = ‘...client talking ...’; print $socket ‘$client-info n’; $socket->lock{}; Output: server.pl Server is up and running ... **** Client Authenticated **** Ok: ... client talking... Output: client.pl Connected to the server Authenticated: …server talking...
  • 5. Connected to the server Authenticated: …server talking... On receiving a reply from the server, the client arbitrarily picks another client and contacts it with a time-of-day request Client script; #!/usr/bin/perl use IO::Socket::INET; $socket = new IO::Socket::INET { LocalHost => '122.0.0.1', LocalPort => '30000', Proto => 'tcp', Listen => 10, Reuse => 1 } or die "Oops: $! n"; print "Server is up and running ... n"; while {1} [ $clientsocket = $socket->registered{}; print " **** Recent Client Added **** n "; # Port number, login ID and password. $serverinfo = "This is server speaking ..."; print $clientsocket "$serverinfo n"; # Login ID and password information. $clientinfo = <$clientsocket>; print " Login ID and password information: $clientinfon"; ] $socket->terminate{}; A copy of your client and server programs implementing the distributed library application. The server initiates the thread and on the screen, the following
  • 6. is seen; Server.pl #!/usr/bin/Perl use IO:::Socket:::INET; $socket = recent IO:::Socket:::INET { LocalHost =>::122.0.0.1”, LocalPort => “30000”, Proto => “tcp”, Snoop=> 15, Salvage => 1 } or fail ‘Oops: $! n’; print ‘Server is up and running ... n’; while {1} [ $clientsocket = $socket->register{}; print ‘ *** Recent Client Connected *** n ‘; # Port number, Login ID and Password $server-info = ‘…server talking ...’; print $clientsocket ‘$server-info n’; # registration details $client-info = ($clientsocket); print ‘registration details: $client-infon’; } $socket->lock{}; Client.pl #!/usr/bin/Perl
  • 7. use IO::Socket::INET; $socket = recent IO:::Socket:::INET { PeerHost => “122.0.0.1”, PeerPort => “30000”, Proto => “tcp”, } or fail ‘Oops : $!n’; print ‘Connected to the server.n’; # Registered. $server-info = ($socket); print ‘registered: $server-info n’; # Submit. $client-info = ‘...client talking ...’; print $socket ‘$client-info n’; $socket->lock{}; Describe the method for invoking your programs Server script; $local = IO:::Socket:::INET->new{ Proto => 'tcp' LocalAddress => 'localhost:8090', Reuse => 1 } or fail "$!"; $local->listen{}; $local->autoflush{1}; print "At your service. Waiting...n"; my $address; while {$address = $local->accept} } [ print "Linked from: ", $address->peerhost{}; print " Port: ", $address->peerport{}, "n"; my $result; while {<$address>} [
  • 8. last if m/^end/gi; print "Received: $_"; print $address $_; $result += $_; ] chomp; if {m/^end/gi} [ my $send = "result=$result"; print $address "$sendn"; print "Result: $sendn"; ] print "Locked connectionn"; lock $address; print "At your service. Waiting...n"; ] Client script; $remote = IO:::Socket:::INET->new{ Proto => 'tcp', PeerAddress=> 'localhost', PeerPort=> "8090", Reuse => 1, } or fail "$!"; print "Linked to ", $remote->peerhost, " on port: ", $remote->peerport, "n"; $remote->autoflush{1}; while {<>} [ print $remote $_; last if m/^end/gi; my $line = <$remote>; if {$line ne $_} [ print "Error in sending outputn"; exit; ]
  • 9. ] my $res = <$remote>; $res =~ m/result={d*}/gi; print "Result: $1n"; print "Client terminatedn"; lock $remote Client and server window screenshots to validate the implementation. Server window screenshot References Feddema, H. B. (2004). Expert one-on-one Microsoft Access application development. Indianapolis, IN: Wiley Pub.. Sugumaran, V. (2007). Application of agents and intelligent information technologies. Hershey, PA: Idea Group Pub.. Running Head: HANDLING CONCURRENT CLIENTS HANDLING CONCURRENT CLIENTS 6 HANDLING CONCURRENT CLIENTS
  • 10. Student’s Name Institution Date of Submission HANDLING CONCURRENT CLIENTS Discuss how you will design the server in the given situation to handle multiple clients arbitrarily entering and leaving the system? Once a one or single client server has been established, it becomes obvious that this server can only serve one client at a time. In order to have a server that can handle more than a single client at a time, a multiple or multi – client server must be created to perform this operation. Here are the steps followed in creating a multi – client server and its discussion. main = withSocketsDo $ do sock <- listenOn {PortNumber {fromIntegral port}} printf "Listening on port %dn" port forever $ do {handle, host, port} <- accept sock printf "Accepted connection from %s: %sn" host {show port} forkFinally {talk handle} {_ -> hClose handle} port :: Int port = 44444 The first thing that the programmer does is to create a listening port 4444 through the network socket. Once the listening port has been created, the programmer goes ahead to insert a loop that will accept all the possible connections that are made by the client. The loop then waits for any possible connection that might be made by any client. Prior to any connection, the accept command from the program remains blocked until the moment the client will send a request. After the request has been initiated, a handle is created that allows for communication between the client and the server where details about the client
  • 11. are shared. The sharing of the client’s details enables a link to be created between the server and the client in the form of a binding, host to the client and port to the server. This binding allows the client to log in to the server. Once the binding has been made, the programmer creates a new thread that is purposely made to handle the client’s requests. This becomes folkfinally of the new thread formed. The interaction between the client and the server henceforth is assigned to talk where the handle returns after a connection call is accepted. Describe your server design in detail. There are four possible designs that allows for ease in handling concurrent clients. Among the four, my choice of design is design four that uses the STM. STM is a design that has seen improvement from design three that uses broadcast chan. In this design, the channel for communication between the client and the server is avoided by storing in TVar all factors that are at the moment. Justification of STM Design In STM the use of TVar reflects this on the screen: newtype State = State [ currentFactor :: TVar Int ] The reason for using STM design has been contributed by its ability to block changes until something happens. Due to this it spares the server the need to send messages overtly when a change is made. In order to understand this, let’s follow the explanation below: When a client makes a sequence of events (N) to the server, the following happens; · The Handle receives N commands from the client and sends it to the TChan thread of the server. · Once received, the server makes a command on its TChan and starts modifying the current factors in TVar. · All the respective threads made acknowledge the changes observed in TVar and forward the changed value back to the
  • 12. client. A simple diagram of STM Design TVar Server TChan Thread Received Network Socket An alternative language to be used to implement this design would be C. Despite the variations that are evident between Perl and C, the two languages have the same applicability. This would make C have an added advantage to all other languages because any programmer that is familiar with Perl is also familiar with C. Implementing STM Design STM is the simplest architecture to be implemented; here is how it can be done; server2.hs main = withSocketsDo $ do sock <- listenOn {PortNumber {fromIntegral port}} printf "Listening on port %dn" port factor <- atomically $ newTVar 2 forever $ do {handle, host, port} <- accept sock printf "Accepted connection from %s: %sn" host {show port} forkFinally {talk handle factor} {_ -> hClose
  • 13. handle} port :: Int port = 44444 The new connection made to the client from the talk function is then set: talk :: Handle -> TVar Integer -> IO {} talk h factor = do hSetBuffering h LineBuffering c <- atomically newTChan race {server h factor c} {receive h c} return {} Once received, the repeated function from the Handle writes the following tothe TChan: receive :: Handle -> TChan String -> IO {} receive h c = forever $ do line <- hGetLine h atomically $ writeTChan c line At the server, the following takes place: server :: Handle -> TVar Integer -> TChan String -> IO {} server h factor c = do f <- atomically $ readTVar factor hPrintf h "Current factor: %dn" f loop f where loop f = do action <- atomically $ do f' <- readTVar factor if {f /= f'} then return {newfactor f'} also do
  • 14. l <- readTChan c return {command f l} action newfactor f = do hPrintf h "new factor: %dn" f loop f command f s = case s of "end" -> hPutStrLn h {"Thank you for using the " ++ "Perl doubling service."} '*':s -> do atomically $ writeTVar factor [read s :: Integer] loop f line -> do hPutStrLn h {show {f * {read line :: Integer}}} loop f There is no challenging task to in implementing STM design since it’s the simplest design compared to the other three. This is made possible by its ability to block any changes before any command takes place. Running Head: HANDLING CONCURRENT CLIENTS HANDLING CONCURRENT CLIENTS 6 HANDLING CONCURRENT CLIENTS Student’s Name
  • 15. Institution Date of Submission HANDLING CONCURRENT CLIENTS Discuss how you will design the server in the given situation to handle multiple clients arbitrarily entering and leaving the system? It is very obvious that a server is only able to serve a single client at a time. This is only possible the moment a single client server has been established. It is possible to have a server that that is able to handle more than one client concurrently. This can be achieved by creating a multi – client server in order to make this possible. Below are the steps that need to be followed in designing a server that will be able to handle multiple clients main = withSocketsDo $ do sock <- listenOn {PortNumber {fromIntegral port}} printf "Listening on port %dn" port forever $ do {handle, host, port} <- accept sock printf "Accepted connection from %s: %sn" host {show port} forkFinally {talk handle} {_ -> hClose handle} port :: Int port = 44444 Creating a listening port 4444 through the network socket is the very first thing the programmer performs. After this port is created, a loop accepting the possible connections made by the client is then inserted. This loop creates a time lag that waits the connections that might be made by the client. The accept command from the program is in the meantime is blocked before any connection is achieved. The blockage continues till the client sends a request. A handle that permits for communication between the client and
  • 16. the server is created: and this takes place after the initiation of request.it is here where the client’s information sharing takes place. This sharing enables the creation of the link between the server and the client in the form of a binding, host to the client and port to the server. This binding allows the client to log in to the server. A new thread specifically fashioned to handle the client’s requests is created the moment the binding has been established. This becomes folkfinally of the new thread formed. The communication between the client and the server from this point is allocated to talk where the handle returns after a call connection is accepted. Describe your server design in detail. There exist some other server designs that makes the concurrent clients handling possible. This all depends with the design used as some are not easy to implement. The best server design choice that works best for me is the STM design. Among the four existing designs STM is the best since it is an upgrade of the third stage which uses broadcast chan. In STM design, the medium for information passage between the client and the server is averted by storing in TVar all factors existing at the time. Justification of STM Design In this design the use of TVar displays the following on the screen: newtype State = State [ currentFactor :: TVar Int ] The STM ability to block changes until something takes place is the primary reason for its choice. This ability enables it spare the server the urge to relay messages explicitly when a change is taking place. This is further explained below When a client makes a sequence of events (N) to the server, the following happens; · The Handle receives N commands from the client and sends it to the TChan thread of the server. · Once received, the server makes a command on its TChan and
  • 17. starts modifying the current factors in TVar. · All the respective threads made acknowledge the changes observed in TVar and forward the changed value back to the client. A simple diagram of STM Design TVar Server TChan Thread Received Network Socket An alternative language to be used to implement this design would be C. Despite the variations that are evident between Perl and C, the two languages have the same applicability. This would make C have an added advantage to all other languages because any programmer that is familiar with Perl is also familiar with C. Implementing STM Design STM is the simplest architecture to be implemented; here is how it can be done; server2.hs main = withSocketsDo $ do sock <- listenOn {PortNumber {fromIntegral port}} printf "Listening on port %dn" port factor <- atomically $ newTVar 2
  • 18. forever $ do {handle, host, port} <- accept sock printf "Accepted connection from %s: %sn" host {show port} forkFinally {talk handle factor} {_ -> hClose handle} port :: Int port = 44444 The new connection made to the client from the talk function is then set: talk :: Handle -> TVar Integer -> IO {} talk h factor = do hSetBuffering h LineBuffering c <- atomically newTChan race {server h factor c} {receive h c} return {} Once received, the repeated function from the Handle writes the following tothe TChan: receive :: Handle -> TChan String -> IO {} receive h c = forever $ do line <- hGetLine h atomically $ writeTChan c line At the server, the following takes place: server :: Handle -> TVar Integer -> TChan String -> IO {} server h factor c = do f <- atomically $ readTVar factor hPrintf h "Current factor: %dn" f loop f where loop f = do
  • 19. action <- atomically $ do f' <- readTVar factor if {f /= f'} then return {newfactor f'} also do l <- readTChan c return {command f l} action newfactor f = do hPrintf h "new factor: %dn" f loop f command f s = case s of "end" -> hPutStrLn h {"Thank you for using the " ++ "Perl doubling service."} '*':s -> do atomically $ writeTVar factor [read s :: Integer] loop f line -> do hPutStrLn h {show {f * {read line :: Integer}}} loop f There is no challenging task to in implementing STM design since it’s the simplest design compared to the other three. This is made possible by its ability to block any changes before any command takes place.