Yes, you can get
fcntl on windows
*. 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:
#include <stdio.h>
#include <fcntl.h>
void SetNonBlocking( int filehandle )
{
int fhFlags;
fhFlags = fcntl(filehandle,F_GETFL);
if (fhFlags < 0)
{
perror("fcntl(F_GETFL)");
exit(1);
}
fhFlags |= O_NONBLOCK;
if (fcntl(filehandle,F_SETFL,fhFlags) < 0)
{
perror("fcntl(F_SETFL)");
exit(1);
}
return;
}
Update:
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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.