Skip to content

Instantly share code, notes, and snippets.

@tacitochaves
Last active August 29, 2015 13:57
Show Gist options
  • Save tacitochaves/9414791 to your computer and use it in GitHub Desktop.
Save tacitochaves/9414791 to your computer and use it in GitHub Desktop.
Atividade 9 com socket
#!/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