Yes, you can get fcntl
. As for using it to do non blocking, I have to admit that I've never done it in Perl. But here is how I do it in C, and I suspect that the Perl way is almost identical:
void SetNonBlocking( int filehandle )
fhFlags = fcntl(filehandle,F_GETFL);
if (fhFlags < 0)
fhFlags |= O_NONBLOCK;
if (fcntl(filehandle,F_SETFL,fhFlags) < 0)
We discover this later
in this thread, but rather deep, so I'll reiterate it here. It turns out that the fcntl
module is available on Win32, but not fcntl(2)
the method. That is *nix specific. Camel2 states, "fcntl
will produce a fatal error if used on a machine that doesn't implement fcntl(2)."
My new recomendation is to use select to poll the socket, and when it has data, then read from it blocking. You can simulate non-blocking by using a small timeout on the select and only reading a few charaters (or even just 1) at a time.
*Note that the standard distribution uses the local c compiler to create Fcntl.pm during install. It is possible then, that someone might not have Fcntl.pm, however ActiveState's distribution of Perl does include it.