如何设置 POE::Filter 来接收从服务器返回的整个数据块?
我尝试了以下方法
my $filter = POE::Filter::Line->new(OutputLiteral => '');
my $wheel = POE::Wheel::ReadWrite->new(
Handle => $socket,
Filter => $filter,
InputEvent => 'on_input',
ErrorEvent => 'on_error',
FlushedEvent => 'on_flush',
);
,但是 on_input 在 ARG0 中每行单独调用了几次。我如何将它们整合在一起?将 OutputLiteral 设置为 '' 不会改变过滤器对“行”的理解吗?
I tried the following
my $filter = POE::Filter::Line->new(OutputLiteral => '');
my $wheel = POE::Wheel::ReadWrite->new(
Handle => $socket,
Filter => $filter,
InputEvent => 'on_input',
ErrorEvent => 'on_error',
FlushedEvent => 'on_flush',
);
But on_input is called several times with each line separately in ARG0. How do I get it all together? Doesn't setting setting OutputLiteral to '' change the filter's understanding of what a "line" is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,您正在从过滤器中读取内容,因此这里重要的是
InputLiteral
,而不是OutputLiteral。
其次,您不能有一个空的InputLiteral< /code> (如果您尝试,它只会自动检测输入文字)。因此,您无法使用 POE::Filter::Line 来获取所有数据,因为它是为了解析行终止记录而设计的。请改用 POE::Filter::Stream
。First of all, you are reading from the filter, so it's
InputLiteral
which is important here, notOutputLiteral.
Second, you can't have an emptyInputLiteral
(if you try, it will just autodetect the input literal). Consequently, you can't usePOE::Filter::Line
to get all the data, because it is made for parsing line-terminated records. UsePOE::Filter::Stream
instead.