in reply to Re^6: ... (Proof!)
in thread Non-blocking Reads from Pipe Filehandle
I used 0. Didn't work.
Probably because your protoype is wrong.
This: my $f = Win32::API->new('kernel32', 'PeekNamedPipe', 'LLLLLL', 'L')
Should be this: my $f = Win32::API->new('kernel32', 'PeekNamedPipe', 'LPLPPP', 'L')
Fix that, and your 'fix' above is unnecessary.
Just another hack at a module that worked fine for the most part before people start trying 'fix it' without enough knowledge to do so.
I wouldn't call it excitement. More depression when I see people proffering this kind unnecessary complexity:
sub get_pv { local $^W; unpack 'L!', pack 'P', $_[0] } BEGIN { # BOOL PeekNamedPipe( # HANDLE hNamedPipe, # LPVOID lpBuffer, # DWORD nBufferSize, # LPDWORD lpBytesRead, # LPDWORD lpTotalBytesAvail, # LPDWORD lpBytesLeftThisMessage # ) my $f = Win32::API->new('kernel32', 'PeekNamedPipe', 'LLLLLL', 'L') or die $^E; sub PeekNamedPipe { my $nBytesRead; my $nTotalBytesAvail; my $nBytesLeftThisMessage; $nBytesRead = pack('L!', $_[3]) if defined $_[3]; $nTotalBytesAvail = pack('L!', $_[4]) if defined $_[4]; $nBytesLeftThisMessage = pack('L!', $_[5]) if defined $_[5]; my $rv = $f->Call( $_[0], get_pv($_[1]), $_[2], get_pv($nBytesRead), get_pv($nTotalBytesAvail), get_pv($nBytesLeftThisMessage), ); $_[3] = unpack('L!', $nBytesRead ) if defined $_[3]; $_[4] = unpack('L!', $nTotalBytesAvail ) if defined $_[4]; $_[5] = unpack('L!', $nBytesLeftThisMessage) if defined $_[5]; return $rv; } }
for the sake of a little reading, and a couple of zeros. The icing on the cake is when they try to claim the technical high ground as justifiction for it.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: ... (Proof!)
by ikegami (Patriarch) on Oct 01, 2008 at 05:31 UTC |