socket编程,client无法先发再收

socket编程,client无法先发再收

解决了:参考http://ubuntuforums.org/archive/index.php/t-336035.html
即使用send和recv,不用<$sock>
但是问题并未得到好的解释


1,client发送完毕,无法print到stdout,只能print到stderr
2,client发送完毕,无法读取socket

附,client
#!/usr/bin/perl -w
use strict;
use IO::Socket;
my $sock = IO::Socket::INET->new(
        PeerAddr => 'localhost',
        PeerPort => 697,
        Proto => 'tcp',);

print $sock "aaaaaaaaa";
#print "enter";
#print STDERR "enter";
my $msg = <$sock>;
print $msg;

printf "FIN";


附,serv
#!/usr/bin/perl -w
use strict;
use IO::Socket;
my $listensock = IO::Socket::INET->new(LocalPort => 697,
        Listen => 10,
        Proto => 'tcp',
        Reuse => 1);

while (my $connsock = $listensock->accept)
{
        my $msg = '\0';
        while ( defined($msg = <$connsock>) )
        {
                print $msg;
        }
        $connsock->send("ok");
        print "sent\n";
}

看到例子是说明client没问题,serv出了什么问题?
$socket = IO::Socket::INET->new( Proto => "tcp", PeerAddr => "$server",  PeerPort => "80");
printf $socket ("GET %s/modules/articles/print.php?id=3/**/UNION/**/SELECT/**/NULL,NULL,NULL,NULL,NULL,pass,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL/**/FROM/**/xoops_users/**/WHERE/**/uid=$uid/* HTTP/1.0\nHost: %s\nAccept: */*\nConnection: close\n\n",
$path,$server,$uid);

while(<$socket>)

{
    if (/\>(\w{32})\</) { print "\nID '$uid' User Password :\n\n$1\n"; }
}
autoflush没有打开吧

[Copy to clipboard] [ - ]
CODE:
select (select ($socket),$|=1)[0];