Perl Socket Minibrowser

Posted by MattMc on Tue 29 Jun 2004 12:42 PM — 5 posts, 22,321 views.

USA #0
Howdy,

Below is a script I'm trying to get to work, but can't seem to figure it out. I admit my native language is php, then vbasic, and then a few other things before I get to perl so I'm really nieve on this language. Below is just the script, not the xml because I do know that much so I won't waste your time by making you flip through there.

I had a friend get this for me, so it may just not be mushclient compatable in its currently writen form. If someone can help me by pointing out the errors on it, or if you have the time to rewrite it that would also be cool, but I just need some guidence.

The object of the script is to seek a website, and return in the @output array the contents of the page. This is used to interface my computer to a php script on a different server so I can post data there, and then return errors or status reports on that post.


see below
Amended on Tue 29 Jun 2004 03:52 PM by MattMc
USA #1
Now that I'm awake... Here's the full file because it actually would help you to see it all after I made some fixes that were pretty obvious. Plus I've included the error I get.


see below
Amended on Tue 29 Jun 2004 05:21 PM by MattMc
USA #2

<script>
<![CDATA[
sub GetHTTP {
  my ($thename, $theoutput, $wildcards) = @_;
  my ($remote, $doc, $port, $iaddr, $paddr, $proto, $line,@output);
  $remote = $world->GetTriggerInfo ($thename,101);
  $doc = $world->GetTriggerInfo ($thename,102);
  $port = 80;
  $sockaddr = 'S n a4 x8';
  if ($port =~ /\D/) { $port = getservbyname($port, 'tcp') }
  die "No port" unless $port;
  $thisaddr   = gethostbyname("localhost");
  $thataddr   = gethostbyname($remote);
  $this   = pack($sockaddr, AF_INET, 0, $thisaddr);
  $that   = pack($sockaddr, AF_INET, $port, $thataddr);

  $proto   = getprotobyname('tcp');
  socket(SOCK, PF_INET, SOCK_STREAM, $proto)  || die "socket: $!";
  bind(SOCK, $this)    || die "bind: $!";
  connect(SOCK, $that)    || die "connect: $!";
  select(SOCK); $| = 1; select(STDOUT);

do { $line = <SOCK> } until ($line =~ /^\r\n/); 
   @output = <SOCK>; 
   close (SOCK) || die "close: $!";
}
]]>
</script>

Poco y poco I'm making my way through, but I think I'm seriously stuck this time :D The bind function isn't recognized.

Error number: -2147467259
Event: Execution of line 1 column 0
Description: bind: Unknown error at (eval 2) line 17.

Called by: Function/Sub: GetHTTP called by trigger
Reason: processing trigger "gethttptrig"
USA #3
Upgraded ActivePerl and same errors.
Amended on Tue 29 Jun 2004 06:10 PM by MattMc
USA #4
If I were to hazard a complete guess on this, it would be that the perl scripting engine can't handle networking. Sorry that I can't help you more than that.