#!/usr/bin/perl use IO::Socket; use Thread; # Wichtige Variablen festsetzen my $HOST = shift || "localhost"; my $PORT = "30381"; my $LOG  = "server_logfile.txt"; my $VERSION = "0.1"; my $server = &Create_Server_Socket(); print "Easyspider Server Version $VERSION bind to $PORT successful: Socket created!\n"; while ($client = $server->accept()) {     $client_ip = getpeername($client);     ($port, $ipaddr) = unpack_sockaddr_in($client_ip);     $client_ip = inet_ntoa($ipaddr);     \&logmsg($LOG,"[$client_ip] Connection attempt!");     if (my $pid = fork) {        close $client or die "Client socket close failed: $!";    } elsif (defined $pid) {         #$client->autoflush(1);         &handle_connection($client,$client_ip);    } else {        die "fork error: $!";    } } ##### Wichtige Soubroutinen sub handle_connection(){     my $client        = @_[0];     my $client_ip    = @_[1];     # handle handshake procedure here     $msg =  <$client>;     if( $msg =~ /c_type=syn\(1\)/ ){         print "[" . localtime() . "] [$client_ip] Connection Setup Procedure SYN Paket recieved!\n";         &send_ack();              }     close $client; } sub send_ack(){     print $client "c_type=ack(1)\015\12";     return 1; } sub Create_Server_Socket(){     my $socket = new IO::Socket::INET(         LocalHost => $HOST,         LocalPort => $PORT,         Proto => 'tcp',         Listen => 2,         Reuse => 1,         Type => SOCK_STREAM,        ) or die "Could not create Socket: $!\n" unless defined($socket);     \&logmsg($LOG,"Easyspider Server Version $VERSION bind to $PORT successful: Socket created!");     print "Easyspider Server Version $VERSION bind to $PORT successful: Socket created!";     return($socket); }# sub Create_Server_Socket(){} ##### Zusätzliche Soubroutinen