The following is the code coming from Uinx Network Programming on page 235:

int flags;

        /* set a socket as nonblocking */
if( (flags = fcntl(fd, F_GETFL, 0)) < 0)
        err_sys("F_GETFL error");
flags |= O_NONBLOCK;        /* This is very inportant or you will clear all other status flags about this file */
if(fcntl(fd, F_SETFL, flags) < 0)
        err_sys("F_SETFL error");

turn off the nonblocking:

flags &= ~O_NONBLOCK;
if(fcntl(fd, F_SETFL, flags) < 0)
        err_sys("F_SETFL error");

相关文章:

  • 2022-01-12
  • 2021-12-13
  • 2021-07-12
  • 2021-06-11
  • 2021-09-29
  • 2021-12-30
  • 2021-07-07
  • 2022-01-03
猜你喜欢
  • 2021-11-05
  • 2021-12-13
  • 2021-08-15
  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
  • 2021-08-31
相关资源
相似解决方案