0
votes

What is the difference between Non blocking and Asynchronous socket modes that we set using below calls.

  1. Case 1: int sockfd; // create_sock(sockfd);

    // init_sock(sockfd);

    fcntl(sockfd, F_SETFL, O_NONBLOCK);

  2. Case 2:

    int sockfd; // create_sock(sockfd);

    // init_sock(sockfd);

    int on = 1;

    ioctl(sockfd, FIOASYNC, &on);

  3. Case 3:

    int sockfd;

    // create_sock(sockfd);

    // init_sock(sockfd);

    int on = 1; ioctl(sockfd, FIONBIO, &on)

What will be the behavior of the socket in all the above cases.

Thanks,

1

1 Answers

1
votes

'Non-blocking' means that the function either did or didn't do something, and returned a status that told you which.

'Asynchronous' means that the operation invoked by the function keeps running after the function returns, and it notifies you of its completion or failure by other means, e.g. a callback or a handle you can interrogate for status.