Recode PERL to PHP

Associate
Joined
10 Dec 2008
Posts
510
Location
127.0.0.1:80
Hi everyone, have written the following in PERL, am trying to get the exact same thing in PHP but can't seem to get it to work.

#! /usr/bin/perl -w
# server0.pl
#--------------------

use IO::Socket;


my $sock = new IO::Socket::INET (
LocalHost => 'x.xx.x.xxx',
LocalPort => 'xxx',
Proto => 'tcp',
Listen => 1,
Reuse => 1,
);
die "Could not create socket: $!\n" unless $sock;


my $new_sock = $sock->accept();
while(<$new_sock>) {

my $now_string = localtime;

open (MYFILE, '>>./client.txt');
print MYFILE " $now_string;$_ \n";
close (MYFILE);

print $_;
}
close($sock);

The above works perfectly in PERL but I can't use it because I can't get the PERL Mysql module to work. PHP is set up perfectly though so if could get the above in PHP would be brilliant.
 
Back
Top Bottom