Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: XML::Parser Streams performing undesired buffering

by Thelonius (Priest)
on Jun 19, 2003 at 21:37 UTC ( #267355=note: print w/replies, xml ) Need Help??


in reply to XML::Parser Streams performing undesired buffering

In Expat/Expat.xs, line 374 in my version reads:
cnt = perl_call_method("read", G_SCALAR);
Change this to:
cnt = perl_call_method("sysread", G_SCALAR);
Then "make install". That should do ya (on Unix-like systems, at least), although I would like to reiterate that a well-formed XML document has a single top-level element, so it can't really be considered parsed until you get to the end.

Another way to do this is to subclass IO::Socket::INET to override the read method.

Update: Here's how you would do the subclassing thing:

use strict; use XML::Parser; use IO::Socket::INET; { package DebufSocket; our @ISA = qw(IO::Socket::INET); sub read { my $self = shift; $self->sysread(@_); } } sub handle_elem_start { my ($expat,$name,$atts) = @_; print "in element \"$name\", at byte ".$expat->current_byte()." in s +tream\n"; } my $sock=DebufSocket->new( PeerAddr => '162.134.173.177', PeerPort => 6537) or die "socket: $!\n"; my $parser=XML::Parser->new( Style => 'Stream', Handlers => { Start => \&handle_elem_start } ); $parser->parse($sock);

Replies are listed 'Best First'.
Re: Re: XML::Parser Streams performing undesired buffering
by lhoward (Vicar) on Jun 20, 2003 at 14:06 UTC
    Thanks for the great suggestions. Thelonius subclassing of IO::Socket::INET solution is the one I ended up going with and it works beautifully.

    Thanks,

    L

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://267355]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2019-12-09 12:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?