Hello.<br>
<br>
I just downloaded the latest version of Perl (ActivePerl-5.6.0.613.msi) for Windows 98. I was very pleased that there is the command FORK for windows users.<br>
<br>
I made use of the socket command and fork and found a serious problem with it. My program acts like a proxy, an middle-man server between my IE5 browser and the actual Internet remote connection. I make a request from IE5, the request gets picked up by my Proxy server, the server makes a separate remote call for the desired site, and returns the data back to the original IE5 call; it FORKs for mutliple calls. Now when I go to use this program, about 10 seconds into it (i don't see anything returned in IE5 though) the perl script crashes popping up a Windows 98 "Illegal Operations" window. Below is the full text reported in DETAILS:<br>
-----<br>
PERL caused an invalid page fault in<br>
module PERL56.DLL at 015f:2806faad.<br>
Registers:<br>
EAX=d9a0dabc CS=015f EIP=2806faad EFLGS=00010a86<br>
EBX=2f62696c SS=0167 ESP=1801fe48 EBP=1801fe54<br>
ECX=00000001 DS=0167 ESI=08fbf064 FS=56bf<br>
EDX=9ed6decc ES=0167 EDI=09034244 GS=6896<br>
Bytes at CS:EIP:<br>
8b 5c 02 fc 8d 34 02 84 d9 75 1e 8b 4d fc 57 39 <br>
Stack dump:<br>
08fbf064 08b7196c 08664db0 1801fea4 280709f1 00000001 2806c050 08663024 09034428 2804b80b 09034428 08b7196c 08fbf064 09034244 09034244 00000000 <br>
---<br>
<br>
I have also attached my proxy server called to this message (below). Simply run it from the DOS command line with: "Perl Proxy.Pl". It will sit there waiting for a call. Now go to your webbrowser and set the proxy server to: localhost (127.0.0.1 port 80). Now type in any remote URL to connect to (ie. <A HREF=" TARGET="_new"> My proxy server will pick up the call and try to make the remote URL call. After about 10 seconds or less the Illegal Operations window (PerlCrash.GIF) will pop up. Maybe it has to do with the new FORK command or perhaps the error has to do with line 39 in my PROXY.PL script which reads: <br>
<br>
$remote1 = IO::Socket::INET->new(Proto=>"tcp", PeerAddr=>"$serv", PeerPort=>"80", Reuse=>1) or goto AX; binmode($remote1);<br>
<br>
This is the line which connects out to the remote URL that the browser is trying to view. Maybe because the browser has to hit the URL multiple times (graphic files + html) fillng up the cue and generating multli calls to line 39 above.<br>
<br>
Well, I hope i've provided enough details. Please let me know what I can do to resolve this problem. I'd very much appreciate that.<br>
<br>
Again, thank you.<br>
<br>
j.<br>
<br>
---PROXY.PL---<br>
use IO::Socket;<br>
<br>
$SIG{CHLD} = sub {wait ()};<br>
<br>
$main_sock = new IO::Socket::INET (LocalHost=>'localhost',LocalPort=>80,Listen=>100,Proto=>'tcp',Reuse=>1,); die "Socket could not be created. Reason: $!\n" unless ($main_sock); <br>
<br>
while ($new_sock = $main_sock->accept())<br>
{<br>
$pid = fork(); die "Cannot fork: $!" unless defined($pid); <br>
<br>
if ($pid == 0) #Handle forked<br>
{<br>
# Child process <br>
if (defined ($buff = <$new_sock>
)<br>
{<br>
# do something with $buff .... <br>
@header = split(' ', $buff);<br>
$method=$header[0]; $url = $header[1]; $httpver=$header[2];<br>
@url=split(/\?--/,$url); $url[0]=~s/http:\/\///g; $url[1]=~s/http:\/\///g;<br>
$url[0]=~/^([^\/]*)(\/[^\{]*)/; $serv=$1; $doc=$2; $url[1]="[1]" if ($url[1]);<br>
<br>
$headext=""; $d=0; $ccl=0;<br>
while($l=<$new_sock>
<br>
{<br>
if ($l=~/Referer: ([^\{]*)/i && $url[1]) {$headext.="Referer: $url[1]\r\n";$d=1; next;}<br>
elsif ($l=~/^\r\n/ && !$d && $url[1])<br>
{$headext.="Referer: $url[1]\r\n";$d=1;}<br>
elsif ($l=~/Content-length: ([0-9]*)/i)<br>
{$ccl=$1;}<br>
$l=~s/\r¦\n//g;<br>
$headext.="$l\r\n";<br>
last if ($l eq ""
;<br>
}<br>
if ($ccl){read($buff,$data,$ccl);$headext.=$data;}<br>
<br>
print "\n\n<Connecting to: print "$method $doc $httpver\n$headext";<br>
<br>
$remote1 = IO::Socket::INET->new(Proto=>"tcp", PeerAddr=>"$serv", PeerPort=>"80", Reuse=>1) or goto AX; binmode($remote1); #die "Can't connect to \"$serv\" $!\n";<br>
<br>
goto AX if (!&ChkSock($remote1));<br>
print $remote1 "$method $doc $httpver\r\n$headext";<br>
$cl=0; $data="";<br>
while ($l=<$remote1>
<br>
{<br>
print $new_sock "$l";<br>
if ($l=~/content-length: ([0-9]*)/i)<br>
{$cl=$1;}<br>
last if ($l=~/^\r\n/ && $cl);<br>
last if (!&ChkSock($remote1));<br>
goto AX if (!&ChkSock($new_sock));<br>
}<br>
if ($cl){read($remote1,$data,$cl);print $new_sock "$data";}<br>
AX: close $remote1;<br>
} <br>
exit(0); # Child process exits when it is done. <br>
} # else 'tis the parent process, which goes back to accept() <br>
} <br>
close ($main_sock); <br>
<br>
sub ChkSock<br>
{<br>
$socks=$_[0];<br>
if (!defined($socks))<br>
{print "\n**CANCELLED**\n";return 0;}<br>
return 1;<br>
}<br>
---
<br>
I just downloaded the latest version of Perl (ActivePerl-5.6.0.613.msi) for Windows 98. I was very pleased that there is the command FORK for windows users.<br>
<br>
I made use of the socket command and fork and found a serious problem with it. My program acts like a proxy, an middle-man server between my IE5 browser and the actual Internet remote connection. I make a request from IE5, the request gets picked up by my Proxy server, the server makes a separate remote call for the desired site, and returns the data back to the original IE5 call; it FORKs for mutliple calls. Now when I go to use this program, about 10 seconds into it (i don't see anything returned in IE5 though) the perl script crashes popping up a Windows 98 "Illegal Operations" window. Below is the full text reported in DETAILS:<br>
-----<br>
PERL caused an invalid page fault in<br>
module PERL56.DLL at 015f:2806faad.<br>
Registers:<br>
EAX=d9a0dabc CS=015f EIP=2806faad EFLGS=00010a86<br>
EBX=2f62696c SS=0167 ESP=1801fe48 EBP=1801fe54<br>
ECX=00000001 DS=0167 ESI=08fbf064 FS=56bf<br>
EDX=9ed6decc ES=0167 EDI=09034244 GS=6896<br>
Bytes at CS:EIP:<br>
8b 5c 02 fc 8d 34 02 84 d9 75 1e 8b 4d fc 57 39 <br>
Stack dump:<br>
08fbf064 08b7196c 08664db0 1801fea4 280709f1 00000001 2806c050 08663024 09034428 2804b80b 09034428 08b7196c 08fbf064 09034244 09034244 00000000 <br>
---<br>
<br>
I have also attached my proxy server called to this message (below). Simply run it from the DOS command line with: "Perl Proxy.Pl". It will sit there waiting for a call. Now go to your webbrowser and set the proxy server to: localhost (127.0.0.1 port 80). Now type in any remote URL to connect to (ie. <A HREF=" TARGET="_new"> My proxy server will pick up the call and try to make the remote URL call. After about 10 seconds or less the Illegal Operations window (PerlCrash.GIF) will pop up. Maybe it has to do with the new FORK command or perhaps the error has to do with line 39 in my PROXY.PL script which reads: <br>
<br>
$remote1 = IO::Socket::INET->new(Proto=>"tcp", PeerAddr=>"$serv", PeerPort=>"80", Reuse=>1) or goto AX; binmode($remote1);<br>
<br>
This is the line which connects out to the remote URL that the browser is trying to view. Maybe because the browser has to hit the URL multiple times (graphic files + html) fillng up the cue and generating multli calls to line 39 above.<br>
<br>
Well, I hope i've provided enough details. Please let me know what I can do to resolve this problem. I'd very much appreciate that.<br>
<br>
Again, thank you.<br>
<br>
j.<br>
<br>
---PROXY.PL---<br>
use IO::Socket;<br>
<br>
$SIG{CHLD} = sub {wait ()};<br>
<br>
$main_sock = new IO::Socket::INET (LocalHost=>'localhost',LocalPort=>80,Listen=>100,Proto=>'tcp',Reuse=>1,); die "Socket could not be created. Reason: $!\n" unless ($main_sock); <br>
<br>
while ($new_sock = $main_sock->accept())<br>
{<br>
$pid = fork(); die "Cannot fork: $!" unless defined($pid); <br>
<br>
if ($pid == 0) #Handle forked<br>
{<br>
# Child process <br>
if (defined ($buff = <$new_sock>
{<br>
# do something with $buff .... <br>
@header = split(' ', $buff);<br>
$method=$header[0]; $url = $header[1]; $httpver=$header[2];<br>
@url=split(/\?--/,$url); $url[0]=~s/http:\/\///g; $url[1]=~s/http:\/\///g;<br>
$url[0]=~/^([^\/]*)(\/[^\{]*)/; $serv=$1; $doc=$2; $url[1]="[1]" if ($url[1]);<br>
<br>
$headext=""; $d=0; $ccl=0;<br>
while($l=<$new_sock>
{<br>
if ($l=~/Referer: ([^\{]*)/i && $url[1]) {$headext.="Referer: $url[1]\r\n";$d=1; next;}<br>
elsif ($l=~/^\r\n/ && !$d && $url[1])<br>
{$headext.="Referer: $url[1]\r\n";$d=1;}<br>
elsif ($l=~/Content-length: ([0-9]*)/i)<br>
{$ccl=$1;}<br>
$l=~s/\r¦\n//g;<br>
$headext.="$l\r\n";<br>
last if ($l eq ""
}<br>
if ($ccl){read($buff,$data,$ccl);$headext.=$data;}<br>
<br>
print "\n\n<Connecting to: print "$method $doc $httpver\n$headext";<br>
<br>
$remote1 = IO::Socket::INET->new(Proto=>"tcp", PeerAddr=>"$serv", PeerPort=>"80", Reuse=>1) or goto AX; binmode($remote1); #die "Can't connect to \"$serv\" $!\n";<br>
<br>
goto AX if (!&ChkSock($remote1));<br>
print $remote1 "$method $doc $httpver\r\n$headext";<br>
$cl=0; $data="";<br>
while ($l=<$remote1>
{<br>
print $new_sock "$l";<br>
if ($l=~/content-length: ([0-9]*)/i)<br>
{$cl=$1;}<br>
last if ($l=~/^\r\n/ && $cl);<br>
last if (!&ChkSock($remote1));<br>
goto AX if (!&ChkSock($new_sock));<br>
}<br>
if ($cl){read($remote1,$data,$cl);print $new_sock "$data";}<br>
AX: close $remote1;<br>
} <br>
exit(0); # Child process exits when it is done. <br>
} # else 'tis the parent process, which goes back to accept() <br>
} <br>
close ($main_sock); <br>
<br>
sub ChkSock<br>
{<br>
$socks=$_[0];<br>
if (!defined($socks))<br>
{print "\n**CANCELLED**\n";return 0;}<br>
return 1;<br>
}<br>
---