use IO::Socket::INET; my $sock = new IO::Socket::INET ( LocalPort => 6547, Listen => 10, Proto => 'tcp', Reuse => 1 ); print "Waiting For Requests!!\n"; while(my $client = $sock->accept()){ print "Connection!\n"; my $blah=<$client>; handle($blah,$client); $client->close(); } sub handle{ my ($data,$client) = @_; chomp($data); my ($command, $param) = split '
',$data; print "$command\n"; if($command == 'start'){ print $client "Welcome to the game: $param\n"; } if($command == 'newUser'){ print $client "$param Has been added to the database!!\n"; } }