F
firenet
My code is like this:
while( 1 )
{
my $i = 0;
my $buffer;
my $from_who = recv( UDP_IN, $buffer, 10, 0 );
if ( $from_who )
{
my ( $the_port, $the_ip ) = sockaddr_in( $from_who );
warn 'Received from ', inet_ntoa( $the_ip ), ": $buffer\n";
$i=$i+1;
print $i."\n";
$data=$data.$buffer;
}
else
{
warn "Problem with recv: $!\n";
}
}
I supposed when i recv a package, $i can increase.But the output is
like this:
Received from 127.0.0.1: bsfsafsfsf
1
Received from 127.0.0.1: sfssfs:w
1
So we can find that the $i increase only one time,where may the problem
be?3ks
while( 1 )
{
my $i = 0;
my $buffer;
my $from_who = recv( UDP_IN, $buffer, 10, 0 );
if ( $from_who )
{
my ( $the_port, $the_ip ) = sockaddr_in( $from_who );
warn 'Received from ', inet_ntoa( $the_ip ), ": $buffer\n";
$i=$i+1;
print $i."\n";
$data=$data.$buffer;
}
else
{
warn "Problem with recv: $!\n";
}
}
I supposed when i recv a package, $i can increase.But the output is
like this:
Received from 127.0.0.1: bsfsafsfsf
1
Received from 127.0.0.1: sfssfs:w
1
So we can find that the $i increase only one time,where may the problem
be?3ks