lhoward has asked for the wisdom of the Perl Monks concerning the following question:
I am interfacing with an existing application that provides an XML event stream over a TCP socket. If I establish a IO::Socket connection without hooking it up to XML::Parser I see the data flow by in real-time. However, when I hook up my socket to XML::Parser, it seems to be buffering IO and then processing a whole bunch at once. Since I want to process the stream more-or-less in realtime; this is undesirable behavior from my point of view. In my experimentation it seems to be buffering data until it gets 32k, then processing that additional stream data. I've checked the docs and module source code but can't find any way to set this buffering size manually. I've encluded example code (with lots of my error checking and other fluff not relevant to the problem at hand) removed:
Is there anyway to set the buffer size? Or to force XML::Parser to process its buffer? Might one of the other XML parsers on CPAN serve me better for the task at hand? Any ideas on how to avoid the unwanted buffering? Luse strict; use XML::Parser; use IO::Socket::INET; my $sock=IO::Socket::INET->new( PeerAddr => '127.0.0.1', PeerPort => 6537); my $parser=XML::Parser->new( Style => 'Stream', Handlers => { Start => \&handle_elem_start } ); $parser->parse($sock); sub handle_elem_start{ my ($expat,$name,&atts)=@_; print "in element \"$name\", at byte ".$expat->current_byte()." in s +tream\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: XML::Parser Streams performing undesired buffering
by Thelonius (Priest) on Jun 19, 2003 at 21:37 UTC | |
by lhoward (Vicar) on Jun 20, 2003 at 14:06 UTC | |
Re: XML::Parser Streams performing undesired buffering
by BrowserUk (Patriarch) on Jun 19, 2003 at 19:43 UTC | |
Re: XML::Parser Streams performing undesired buffering
by bobn (Chaplain) on Jun 19, 2003 at 19:21 UTC |
Back to
Seekers of Perl Wisdom