#!/usr/local/bin/perl $port = shift; # from wwwclient.pl # from /usr/include/linux/socket.h $AF_INET=2; $SOCK_STREAM=1; $PF_INET=$AF_INET; # # if ($url =~ m!http://([^/]*)(/.*)!) {$them=$1;$file=$2;} # if ($them =~ /(.*):([0-9]*)/) {$them=$1;$port=$2;} # # ($them,$port) = @ARGV; $port = 8081 unless $port; # And here's a server: $newport=$port; $sockaddr = 'S n a4 x8'; ($name, $aliases, $proto) = getprotobyname('tcp'); ($name, $aliases, $newport) = getservbyname($newport, 'tcp') unless $newport =~ /^\d+$/; $this = pack($sockaddr, $AF_INET, $newport, "\0\0\0\0"); select(NETSCAPE); $| = 1; select(stdout); socket(S, $PF_INET, $SOCK_STREAM, $proto) || die "socket: $!"; bind(S, $this) || die "bind: $!"; listen(S, 5) || die "connect: $!"; select(S); $| = 1; select(stdout); for (;;) { print "Listening again $port\n"; ($addr = accept(NETSCAPE,S)) || die $!; print "accept ok\n"; ($af,$newport,$inetaddr) = unpack($sockaddr,$addr); @inetaddr = unpack('C4',$inetaddr); print "$af $newport @inetaddr\n"; ################## $ihport=80; $sockaddr = 'S n a4 x8'; chop($hostname = `hostname`); ($name, $aliases, $proto) = getprotobyname('tcp'); ($name, $aliases, $ihport) = getservbyname($ihport, 'tcp') unless $ihport =~ /^\d+$/; ($name, $aliases, $type, $len, $thisaddr) = gethostbyname($hostname); ($name, $aliases, $type, $len, $thataddr) = gethostbyname($them); $this = pack($sockaddr, $AF_INET, 0, $thisaddr); $that = pack($sockaddr, $AF_INET, $ihport, $thataddr); socket(HTTPD, $PF_INET, $SOCK_STREAM, $proto) || die "socket: $!"; bind(HTTPD, $this) || die "bind: $!"; connect(HTTPD, $that) || die "connect: $!"; select(HTTPD); $| = 1; select(NETSCAPE); $| = 1; select(stdout); $|=1; ######################################## $Contentslength=0; while () { # HTTPD print length; print; print HTTPD; /^Content-length: ([0-9]*)/ && do {print $Contentslength=$1 ; print "<>"}; /^\r*$/ && last; # CRNL } # /^Content-type: application/x-www-form-urlencoded/; print "Contentslength: ",$Contentslength,"\n jjj\niii" ; if ($Contentslength) { print "Contentslength: ",$Contentslength ; while (0) # read (NETSCAPE,$bufer,1) { # print 1,"\n"; print; print HTTPD $bufer; } } # print time," GET $file HTTP/1.0\n\n"; print "GET $file HTTP/1.0\n\n"; $bufersize=64*1024; while ( read(HTTPD,$bufer,$bufersize)) { print NETSCAPE $bufer, "\n"; } # print time; ################## }


Home | UK Shop Center |Contact | Buy Domain | Directory | Web Hosting | Resell Domains


Copyleft 2005 ruslib.us