@@ -16,10 +16,11 @@ #include #include #include #include +#include #import "OFStream.h" #import "OFString.h" #import "OFDataArray.h" #import "OFExceptions.h" @@ -39,10 +40,11 @@ self = [super init]; cache = NULL; wBuffer = NULL; + isBlocking = YES; return self; } - (BOOL)_isAtEndOfStream @@ -670,10 +672,38 @@ } /* Get rid of a warning, never reached anyway */ assert(0); } + +- (BOOL)isBlocking +{ + return isBlocking; +} + +- (void)setBlocking: (BOOL)enable +{ +#ifndef _WIN32 + int flags; + + isBlocking = enable; + + if ((flags = fcntl([self fileDescriptor], F_GETFL)) == -1) + @throw [OFSetOptionFailedException newWithClass: isa]; + + if (enable) + flags &= ~O_NONBLOCK; + else + flags |= O_NONBLOCK; + + if (fcntl([self fileDescriptor], F_SETFL, flags) == -1) + @throw [OFSetOptionFailedException newWithClass: isa]; +#else + @throw [OFNotImplementedException newWithClass: isa + selector: _cmd]; +#endif +} - (int)fileDescriptor { @throw [OFNotImplementedException newWithClass: isa selector: _cmd];