[Topic also posted in alt.comp.lang.l earn.c-c++]
Hello,
I couldn't find a solution to the following problem (tried
google and dejanews), maybe I'm using the wrong keywords?
Is there a way to open a file (a linux fifo pipe actually) in
nonblocking mode in c++? I did something ugly like
--- c/c++ mixture ---
mkfifo( "testpipe", 777);
int fdesc = open( "testpipe", O_RDONLY|O_NONB LOCK);
while( true)
{
bytes_read = read( fdesc, inbuffer, 255);
if( bytes_read > 0)
std::cerr << "Read " << inbuffer << std::endl;
else
{
std::cerr << "Nothing to read here!" << std::endl;
usleep( 250000);
}
}
--- end ---
Now I want the same result in c++, there has to be some flag
or fctrl or something?
Thanx for any help,
Mario
Hello,
I couldn't find a solution to the following problem (tried
google and dejanews), maybe I'm using the wrong keywords?
Is there a way to open a file (a linux fifo pipe actually) in
nonblocking mode in c++? I did something ugly like
--- c/c++ mixture ---
mkfifo( "testpipe", 777);
int fdesc = open( "testpipe", O_RDONLY|O_NONB LOCK);
while( true)
{
bytes_read = read( fdesc, inbuffer, 255);
if( bytes_read > 0)
std::cerr << "Read " << inbuffer << std::endl;
else
{
std::cerr << "Nothing to read here!" << std::endl;
usleep( 250000);
}
}
--- end ---
Now I want the same result in c++, there has to be some flag
or fctrl or something?
Thanx for any help,
Mario
Comment