Leser: 2
|< 1 2 >| | 11 Einträge, 2 Seiten |
Quote# create a socket, make it reusable
socket(SERVER, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
setsockopt(SERVER, SOL_SOCKET, SO_REUSEADDR, 1) or die "setsock: $!";
# grab a port on this machine
my $paddr = sockaddr_in($port, INADDR_ANY);
# bind to a port, then listen
bind(SERVER, $paddr) or die "bind: $!";
listen(SERVER, 5) or die "listen: $!";
print "SERVER started on port $port\n";
Quotewhile ($client_addr = accept(CLIENT, SERVER)) {
#add ip to logfile
my ($client_port, $client_ip) = sockaddr_in($client_addr);
my $client_ipnum = inet_ntoa($client_ip);
#print LOGFILE "connection from: [$client_ipnum]\n";
while (<CLIENT>) {
recv (CLIENT, $output, 1024, 0);
@output_a = split(" ",$output);
if (!$output_a[0]) {
$output_a[0] = $output;
};
#add command to logfile
#print LOGFILE "$output\n";
if ($output_a[0] eq "login") {
if ($output_a[1] eq $password) {
$login = 1;
send(CLIENT,"erfolgreich eingeloggt<br>\n",100,0);
};
};
if ($login != 1) {
send(CLIENT,"login: $output_a[0] $output_a[1] \n",100,0);
#Sie haben sich nicht eingeloggt. Beende Verbindung.\n
sleep(1);
close CLIENT;
last;
};
while ($output = <CLIENT>) {
|< 1 2 >| | 11 Einträge, 2 Seiten |