[Israel.pm] does anyone understand why this code is not working?

liat rin_liat at netvision.net.il
Sat Jul 17 04:33:44 PDT 2004


networking is not my problem becuase i succeed already to move data between
the client and server cause they are connected
also succeed to move Storable data of a hash
someone from here suggest me to check the size of the data B4 moving it to
the client cause the client
needs to know how many bytes he is going to receive.
thats why i try to get the size of the list .
and i tried also the "scalar" functios . it returnes the scalar "5" as for
the number of the list lines.
so it isn't helping . i need the number of bytes....
i choose N cause it's a network maybe also V can help . i'll try. what is
the differente between "network" and "little-endian" ?



-----Original Message-----
From: perl-bounces at perl.org.il [mailto:perl-bounces at perl.org.il]On Behalf Of
Yuval Yaari
Sent: Saturday, July 17, 2004 1:07 AM
To: perl at perl.org.il
Subject: Re: [Israel.pm] does anyone understand why this code is not
working?


This is NOT the problem but:
$urls_lenght should be $urls_length

Also:
$urls_lenght = pack('N', at urls_lines);
should be:
$urls_lenght = pack('N*', at urls_lines);
or
$urls_lenght = pack('N',scalar(@urls_lines));
[depends on what you want to achieve. same thing for the coresponding
unpack]
I'm not such a low-level-stuff (read: LSB vs MSB) kind of person, but was
there a reason you chose N over V?

are Client & SOCK contants or what???
Can we see a broader part of the script?
I think sending a much bigger buffer (I always use 1024, I don't even
remember why :)) is ok, and better than just using the length of
something.

Also try sending non-Storable data first to weed the option that
networking is your problem out.

  --Yuval

liat said:
> hellow all,
> I try to move a LIST from server to client and it is not working
> i use the pack/unpack functions.
>  i think i miss something and it's not working
> i also tried to get the size of the list using the length functions and
> send the "size" to the client and it's not working
> The Error i get is:
> "Magic number checking on storable string failed at
> ..\..\lib\Storable.pm <autosplit into
> ..\..\lib\auto\Storable\thaw.al> line 358. at C:\liatperl\COPYOF~4.CGI
> line 27"
> and line 27 is on the client side:"my @urls_lines = @{
> thaw($urls_serialized) }; "
>
> if anyone knows this error plz let me know what's wrong..
> thanks
>  Liat
>
>
>
> the server side:
>    open(FILE,"url");
>    my @urls_lines = <FILE>; # slurps all the file.
>    my $urls_serialized = nfreeze(\@urls_lines);
>    my $urls_lenght = pack('N', length($urls_serialized)); ## or my
> $urls_lenght = pack('N', at urls_lines);
>    send(client, $urls_lenght, 4);
>    send(Client, $urls_serialized,length($urls_serialized),);
>
> the client side:
>     my $urls_lenght;
>     my $urls_serialized;
>     recv(SOCK, $urls_lenght,4,0)or die "recv() failed: $!";
>     $urls_lenght = unpack ('N', $urls_lenght);
>     recv(SOCK, $urls_serialized,$urls_lenght,0);
>     my @urls_lines = @{ thaw($urls_serialized) };
>
>
> _______________________________________________
> Perl mailing list
> Perl at perl.org.il
> http://perl.org.il/mailman/listinfo/perl



_______________________________________________
Perl mailing list
Perl at perl.org.il
http://perl.org.il/mailman/listinfo/perl





More information about the Perl mailing list