[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] TCP Scripting



Just read about the following link on Macintouch:

    http://www.scripting.com/frontier/netScripting/tcp/netEventsInterface.html

It is an AppleEvents package for AppleScript and Frontier (and other
languages that control AppleEvents) for writing/reading TCP streams.

And I was thinking, yeah, but you could also just learn Perl ...

I tried it out a bit from MacPerl, and got some of it to work.  But it
would be a whole lot easier to just write:

#!perl
use Socket;
$remote  = 'bolo.usu.edu'                       || shift;
$port    = '50000'                              || shift;
$iaddr   = inet_aton($remote)                   || die "no host: $remote";
$paddr   = sockaddr_in($port, $iaddr);
$proto   = getprotobyname('tcp');
socket(SOCK, PF_INET, SOCK_STREAM, $proto)      || die "socket: $!";
connect(SOCK, $paddr)                           || die "connect: $!";
while(<SOCK>) {print}
close(SOCK);
__END__

#================================================================
Chris Nandor                                      pudge@pobox.com
PGP Key 1024/B76E72AD                           http://pudge.net/
Keyfingerprint = 08 24 09 0B CE 73 CA 10  1F F7 7F 13 81 80 B6 B6