Hi Alek,

The fcntl way may be better done like below, as the original flags get
saved.

Regards, Stuart.

#include <unistd.h>
#include <fcntl.h>
#include <errno.h>

int non_block(int fd)
{
    int flags;

    if( (flags = fcntl(fd, F_GETFL)) < 0 ) {
        return -1;
    }
    if( fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0 ) {
        return -1;
    }
    return 0;
}


Aleksandar Bakic wrote:
> 
> "Michael Frank" <[EMAIL PROTECTED]> writes:
> 
> > The right option to make socket non-blocking one is
> >
> >    fcntl(fd, F_SETFL, O_NONBLOCK)
> 
> Hm... I actually used this in one application long time ago, but
> removed it because it behaved strangely. (Could be just that some data
> were lost due to lack of buffer space; the TCP_NODELAY seemed better,
> although I can't remember exactly what it does.)
> 
> Thanks,
> Aleks

--- [rtl] ---
To unsubscribe:
echo "unsubscribe rtl" | mail [EMAIL PROTECTED] OR
echo "unsubscribe rtl <Your_email>" | mail [EMAIL PROTECTED]
----
For more information on Real-Time Linux see:
http://www.rtlinux.org/~rtlinux/

Reply via email to