以下代码在 Windows 7 Pro 上产生错误,它读取 5-8K 字节的网页,然后终止:
use strict;
use LWP::UserAgent;
my $url = 'https://www.flickr.com/photos/71475421@N02/26176178323/';
my $ua = LWP::UserAgent->new;
my $res = $ua->get($url);
print $res->headers->as_string;
错误是:
X-Died: read failed: A non-blocking socket operation could not be
completed immediately. at C:/Perl/lib/LWP/Protocol/http.pm line 467.
操作系统:Win 7 Pro(64位)
Perl:5.20.1(32 位)
轻量化:6.08
LWP-协议(protocol)-https:6.06
任何想法为什么它不起作用,以及如何修复它?
谢谢。
最佳答案
这个问题可能是由于只检查 EAGAIN 而不是 EWOULDBLOCK。这些错误代码在大多数 UNIX 上都是相同的,但在 Windows 上是不同的。我建议使用更新版本的 LWP(至少 6.09 版),因为它明确地处理了这个问题并检查了这两种情况。
关于perl - Perl 的 LWP::UserAgent 包中的 "Non-blocking socket operation"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36993205/