I want to port my code from linux to windows. It is something like this:
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;
}
Now I want have same in windows. Any ideas? Actualy my filehandle is read side of pipe which is created via WinApi CreatePipe method.
The Windows API function
CreateNamedPipehas an option to make the handle non-blocking. (See MSDN). Also see the MSDN article on Synchronous and Overlapped I/O. BTW, you can directly compile POSIX compliant code on Windows using MinGW or Cygwin and thus avoid the headache of porting.