aio_read Help

D

danu

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.
 
K

Keith Thompson

danu said:
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.
 
F

Flash Gordon

danu said:
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.

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

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

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.
 
W

William Ahern

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,188
Messages
2,571,002
Members
47,591
Latest member
WoodrowBut

Latest Threads

Top