Last active
August 29, 2015 13:57
-
-
Save tacitochaves/9414791 to your computer and use it in GitHub Desktop.
Atividade 9 com socket
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use IO::Socket::INET; | |
use strict; | |
my $server_socket = IO::Socket::INET->new( | |
'LocalAddr' => '0.0.0.0', | |
'LocalPort' => '8086', | |
'Proto' => 'tcp', | |
'Reuse' => 1, | |
'Listen' => 1, | |
) or die "Não foi possíl criar o socket. ($!)\n"; | |
print "\n * Servidor ativo * \n"; | |
my $cliente = $server_socket->accept; | |
print $cliente " ------------------------------ \r\n"; | |
print $cliente " * Serviço ativo * \r\n"; | |
print $cliente " ------------------------------ \r\n"; | |
print $cliente " Digite a senha de acesso:"; | |
while (<$cliente>) { | |
my $senha = "$_" ; | |
my $pass = "abcd1234"; | |
print "$senha"; | |
if ( "$senha" == "$pass" ) { | |
print $cliente "Acesso permitido.\n"; | |
} else { | |
print $cliente "Acesso negado.\n" | |
} | |
} | |
print "\n-----------------"; | |
system "sleep 60"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment