Saturday, February 18, 2012

writev example linux


2 comments:

  1. Why no error handling from writev

    ReplyDelete
    Replies
    1. Hi,

      Yes it is better to have a error check always, we missed that. You can use the following point to add the return check,
      "writev() return the number of bytes written. On error, -1 is returned, and errno is set appropriately."

      // make sure to add
      if (writev(1, iov, 3) == -1)
      {
      printf ("ERROR : writev failed - %s\n",strerror(errno));
      }
      else
      {
      printf ("written - %d bytes\n", writev(1, iov, 3));
      }

      Delete