On Thu, 13 Jan 2011 02:14:36 PST
"Alex B." <box...@gmail.com> wrote:

> Hi,
> 
> I know that with fcntl() I can configure a socket to be non-blocking:
> fcntl(socket, F_SETFL, O_NONBLOCK);
> (with O_NONBLOCK attribute), but how do I configure a socket to be
> blocking - as opposite to "non-blocking"? Thanks!
> -- 
> This message posted from opensolaris.org
> _______________________________________________
> opensolaris-code mailing list
> opensolaris-code@opensolaris.org
> http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

I think it's better to use ioctl(), it's only one system call. With
fcntl() you need to call fcntl() to get descriptor's current status
flags, then call fcntl() again to set them.

int int_val;
int connfd;

/* Set socket non-blocking */
int_val = 1;
ioctl(connfd, FIONBIO, &int_val);

/* Set socket blocking */
int_val = 0;
ioctl(connfd, FIONBIO, &int_val);
_______________________________________________
opensolaris-code mailing list
opensolaris-code@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to