aio_read Help

Discussion in 'C Programming' started by danu, Aug 1, 2006.

  1. danu

    danu Guest

    I'm trying to read asynchronously from a file using aio_read:

    /* async I/O structures */
    struct aiocb cb;
    const struct aiocb* list[1] = { &cb };
    int aioRet;

    /* set appropriate values in control buffer */
    cb.aio_fildes = fromfd;
    cb.aio_buf = buffer0;
    cb.aio_nbytes = BUFSIZE;
    cb.aio_sigevent.sigev_notify = SIGEV_NONE;

    while(1) {

    /* copy one block asynchronously */
    aioRet = aio_read(&cb);

    if (aioRet == -1) {
    fprintf(stderr, "%s", " aio_read failed:: ");
    perror("");
    exit(EXIT_FAILURE);
    };
    count++;
    if(count == 5) break;

    }

    But when I tried to do this I'm getting an error message saying:
    aio_read failed:: Invalid argument

    I can't move on further in my program because of this read failure.
    what's the reason for this?
    I highly suspect it's because I'm trying to do aio_read in a while
    loop. (when I remove the while loop it seem works) How do I fix this.
    Do I have to use aio_suspend ? I tried that but it didn't resolve the
    issue. may be I'm using it in a wrong way.

    any help would be highly appreciated. Thanks in advance guys.
     
    danu, Aug 1, 2006
    #1
    1. Advertising

  2. "danu" <> writes:
    > I'm trying to read asynchronously from a file using aio_read:

    [snip]

    aio_read is not standard C. Try asking in a newsgroup that's specific
    to your system.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Aug 1, 2006
    #2
    1. Advertising

  3. danu

    Flash Gordon Guest

    danu wrote:
    > I'm trying to read asynchronously from a file using aio_read:


    Good luck, aio_read is not part of the C standard so we don't know
    anything about it.

    >
    > /* async I/O structures */
    > struct aiocb cb;


    Perhaps you should do:
    struct aiocb cb = { 0 };
    to ensure all fields are initialised.

    <snip>

    > /* copy one block asynchronously */
    > aioRet = aio_read(&cb);
    >


    <snip>

    > But when I tried to do this I'm getting an error message saying:
    > aio_read failed:: Invalid argument


    <snip>

    > any help would be highly appreciated. Thanks in advance guys.


    Try asking in a group dedicated to your system. There you might find
    someone who knows about aio_read.
    --
    Flash Gordon
    Still sigless on this computer.
     
    Flash Gordon, Aug 1, 2006
    #3
  4. On Mon, 31 Jul 2006 23:17:13 -0700, danu wrote:

    > I'm trying to read asynchronously from a file using aio_read:
    >
    > /* async I/O structures */
    > struct aiocb cb;
    > const struct aiocb* list[1] = { &cb }; int aioRet;
    >
    > /* set appropriate values in control buffer */
    > cb.aio_fildes = fromfd;
    > cb.aio_buf = buffer0;
    > cb.aio_nbytes = BUFSIZE;
    > cb.aio_sigevent.sigev_notify = SIGEV_NONE;
    >
    > while(1) {
    >
    > /* copy one block asynchronously */
    > aioRet = aio_read(&cb);
    >
    > if (aioRet == -1) {
    > fprintf(stderr, "%s", " aio_read failed:: "); perror("");
    > exit(EXIT_FAILURE);
    > };
    > count++;
    > if(count == 5) break;
    >
    >
    > }
    > But when I tried to do this I'm getting an error message saying: aio_read
    > failed:: Invalid argument
    >
    > I can't move on further in my program because of this read failure. what's
    > the reason for this?
    > I highly suspect it's because I'm trying to do aio_read in a while loop.
    > (when I remove the while loop it seem works) How do I fix this. Do I have
    > to use aio_suspend ? I tried that but it didn't resolve the issue. may be
    > I'm using it in a wrong way.


    It would indeed look like you're using aio_read improperly. Nothing you're
    doing is asynchronous.

    > any help would be highly appreciated. Thanks in advance guys.


    Try comp.unix.programmer. The POSIX AIO interface is newish, so you might
    have to exercise some patience.
     
    William Ahern, Aug 1, 2006
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?dHJlbGxvdzQyMg==?=

    HELP! HELP! HELP! Opening Web Application Project Error

    =?Utf-8?B?dHJlbGxvdzQyMg==?=, Feb 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    776
    =?Utf-8?B?dHJlbGxvdzQyMg==?=
    Feb 20, 2004
  2. Harvey
    Replies:
    0
    Views:
    722
    Harvey
    Jul 16, 2004
  3. Harvey
    Replies:
    1
    Views:
    858
    Daniel
    Jul 16, 2004
  4. =?Utf-8?B?S2ltb24gSWZhbnRpZGlz?=

    HELP - HELP - HELP

    =?Utf-8?B?S2ltb24gSWZhbnRpZGlz?=, Mar 9, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    689
    Eliyahu Goldin
    Mar 9, 2006
  5. yueyu
    Replies:
    0
    Views:
    390
    yueyu
    Jan 23, 2007
Loading...

Share This Page