[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] I can't believe I got this far...
Honest to Goodness <h2g@sympatico.ca> writes:
> I now have a GlobalSub (which is considered unsafe, but would a usertag
> still be able to Use::Socket?)
A GlobalSub is per se not unsafe (depends on the implementation), but
AllowGlobal is. IMHO you can do almost anything with a global usertag which
is possible with a GlobalSub. Here is an example with use Socket:
UserTag deliver_agent Order host port input
UserTag deliver_agent Routine <<EOS
sub {
use Socket;
my ($host, $port, $input) = @_;
my ($iaddr, $paddr, $proto);
my ($line, $bytes);
# Log ("HOST: $host PORT: $port");
$iaddr = inet_aton ($host);
$paddr = sockaddr_in ($port, $iaddr);
# Log ("Have ADDR in");
$proto = getprotobyname ('tcp');
unless (socket (SOCK, PF_INET, SOCK_STREAM, $proto)) {
Log ("socket: $!\n");
return;
}
# Log ("Have Socket");
unless (connect (SOCK, $paddr)) {
Log ("connect failed: $!\n");
return;
}
# Log ("Have Connection");
unless (syswrite (SOCK, $input, 31) == 31) {
Log ("write failed\n");
return;
}
unless (($bytes = sysread (SOCK, $line, 77)) == 77) {
Log ("read failed (bytes: $bytes): $!\n");
return;
}
# Log ("SOCK: $line");
unless (close (SOCK)) {
Log ("socket close: $!\n");
return;
}
substr ($line, 31);
};
EOS
Ciao
Racke
--
Think of it !
For projects and other business stuff please refer to COBOLT NetServices
(URL: http://www.cobolt.net; Email: info@cobolt.net; Phone: 0041-1-3884400)