Un logger smnp pour les linksys
use strict
;
use warnings
;
use IO
::Socket;
use FileHandle
;
use File
::Temp qw/ tempfile tempdir /;
use File
::Copy;
&bindServer
();
sub bindServer
{
# Open & Listen
my $serverSocket = new IO
::Socket::INET(
LocalHost
=> '192.168.0.101',
LocalPort
=> '162',
Proto
=> 'udp',
# Listen => SOMAXCONN,
Type
=> SOCK_DGRAM
,
Reuse
=> 1);
$serverSocket or die("Unable to bind :$!");
my($clientSocket, $c_addr, $buffer,$clientAddress);
# Waiting for call...
print( "Listening ...");
while (($clientSocket, $clientAddress) = $serverSocket->accept())
{
# Get "client" identity
my ($clientPort, $c_ip) =sockaddr_in
($clientAddress);
my $clientIP = inet_ntoa
($c_ip);
my $clientHost =gethostbyaddr($c_ip, AF_INET
);
while (defined ($buffer = <$clientSocket>))
{
print $buffer;
}
}
}
Poster un nouveau commentaire