Hello Sun-managers,
I solved my problem using the script h2ph included in perl 5.x. This way,
the script generates all *.ph and then, I used socket.ph (that was among
them) in my script.
I generated all *.ph this way:
#cd /usr/include; h2ph * sys/*
I used the socket function like this:
...
socket(PASSD,&PF_INET,&SOCK_STREAM,$proto) || die "socket: $!";
...
Regards,
-
Luiz Morte da Costa Junior. E-mail: morte@correionet.com.br
Analista de Redes http://www.correionet.com.br
CorreioNet - Correio Popular Tel: +55 (19) 754-2530
Campinas, SP - Brasil
Thanks to:
"K.Ravi" <RAVKRISH.IN.oracle.com.ofcmail@in.oracle.com>
Casper Dik <casper@holland.Sun.COM>
"Karl E. Vogel" <vogelke@c17mis.region2.wpafb.af.mil>
Christian Lotz <lotz@suk.net>
"Tony C. Wu" <tonywu@life.nthu.edu.tw>
Daniel Kluge <danielk@tibco.com>
Matthew Stier <Matthew.Stier@tddny.fujitsu.com>
Gustavo Chaves <gustavo@cpqd.br>
Jeff Graham <demit@best.com>
On Wed, 15 Oct 1997, Luiz Morte da Costa Junior wrote:
>
> Hello Sun-managers,
>
> I have a perl script that uses socket. I copied an example (*) from a perl
> book and it works in Linux, but it's not working in a Sun. The error
> appears in socket function.
>
> Can you ligth my way?
>
> -
> Luiz Morte da Costa Junior. E-mail: morte@correionet.com.br
> Analista de Redes http://www.correionet.com.br
> CorreioNet - Correio Popular Tel: +55 (19) 754-2530
> Campinas, SP - Brasil
>
>
>
> 1. Machines
> Sun: Ultra 1, com Solaris 2.5.1
> Linux: kernel 2.0.30
>
>
>
> 2. Script (*)
> #!/usr/local/bin/perl
>
> ($them,$port) = @ARGV;
>
> $port = 2345 unless $port;
> $them = 'localhost' unless $them;
>
> $AF_INET = 2;
> $SOCK_STREAM = 1;
>
> $SIG{'INT'} = 'dokill';
> sub dokill {
> kill 9,$child if $child;
> }
>
> $sockaddr = 'Sna4x8';
>
> chop($hostname = `hostname`);
>
> ($name,$aliases,$proto) = getprotobyname('tcp');
> ($name,$aliases,$port) = getservbyname($port,'tcp');
> ($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, $port, $thataddr);
>
>
> if (socket(S, $AF_INET, $SOCK_STREAM, $proto) )
> {
> print "socket ok.\n";
> }
> else { print "Error socket";exit; }
>
>
> if (bind(S, $this))
> {
> print "bind ok.\n";
> }
> else { print "Error bind";exit; }
>
> if (connect(S, $that))
> {
> print "connect ok.\n";
> }
> else { print "Error connect";exit; }
>
> select(S); $| = 1; select(STDOUT);
>
> if ($child = fork)
> {
> while (<STDIN>) { print S; }
> sleep 3;
> do dokill();
> }
> else {
> while(<S>) { print; }
> }
>
>
-
Luiz Morte da Costa Junior. E-mail: morte@correionet.com.br
Analista de Redes http://www.correionet.com.br
CorreioNet - Correio Popular Tel: +55 (19) 754-2530
Campinas, SP - Brasil
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:06 CDT