Perl Programming Write client and server programs to implement a simple client-s
ID: 3697198 • Letter: P
Question
Perl Programming
Write client and server programs to implement a simple client-server authentication system. You will be able to implement and test both the client and server programs on a single machine by running them on different ports with the same Internet Protocol (IP) address. Your program must take care of the following:
•At the client end, provide a menu such as: Register Authenticate yourself
•If a user selects Register, get the login ID and password from the user and contact the server with the information required for registration. The server maintains a file with a list of client login IDs and associated passwords. The server updates this file with the registration information provided by the new user.
•If a user selects Authenticate yourself, get the login ID and password from the user. Send this information to the server for authentication. The server authenticates the user by performing a password lookup and sending a "Client Authenticated" or "Client Not Authenticated" message. This is required to implement the JOIN feature in your distributed library implementation.
Explanation / Answer
server.pl
#!/usr/bin/perl
use IO::Socket::INET;
$socket = new IO::Socket::INET (
LocalHost => '127.0.0.0',
LocalPort => '100',
Proto => 'tcp',
Listen => 10,
Reuse => 1
) or die "Oops: $! ";
print "Server is up and running ... ";
while (1) {
$clientsocket = $socket->accept();
print " connected ";
$serverdata = "running";
print $clientsocket "$serverdata ";
$clientdata = <$clientsocket>;
print "Message received from Client : $clientdata ";
}
$socket->close();
Source: client.pl
#!/usr/bin/perl
use IO::Socket::INET;
$socket = new IO::Socket::INET (
PeerHost => '127.0.0.0',
PeerPort => '100',
Proto => 'tcp',
) or die "Oops : $! ";
print "Connected ";
$serverdata = <$socket>;
print "Message from Server : $serverdata ";
$clientdata = "running";
print $socket "$clientdata ";
$socket->close();
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.