Fcntl filehandle, function, scalar
Implements the fcntl (2) function. You'll probably have to say
Use Fcntl;
First to get the correct constant definitions. Argument processing and value returned work just likeIOCTLBelow. For example:
use fcntl ;
fcntl ( $ filehandle , f_getfl , $ packed_return_buffer )
or die " can't fcntl f_getfl: $! " ;
You don't have to checkDefinedOn the return fromFcntl. LikeIOCTL, It maps0Return from the system call"0 but true"In Perl. This string is true in Boolean context and0In numeric context. It is also exempt from the normal-WWarnings on improper Numeric conversions.
Note thatFcntlRaises an exception if used on a machine that doesn't implement fcntl (2). See the fcntl module or your fcntl (2) manpage to learn what functions are available on your system.
Here's an example of setting a filehandle namedRemoteTo be non-blocking at the system level. You'll have to negotiate$ |On your own, though.
Use Fcntl QW (f_getfl f_setfl o_nonblock );
$ Flags = Fcntl (Remote , F_getfl , 0 )
Or Die " Can't get flags for the socket: $! \ N " ;
$ Flags = Fcntl (Remote , F_setfl , $ Flags | O_nonblock)
Or Die " Can't set flags for the socket: $! \ N " ;