hello everyone,
i'm very hope so anyone ere have experience with lib rt like aio linux based.
I've a problem with receiving data from aio_buf, i.e. I have received it, but if the next data size less then pervious I've got a noise from a socket.
I've tried to fix it by different ways, but unfortunately still didn't.
Assuming that aio_buf is a char array, it looks a lot like you aren't null terminating the string
before printing it, and aio_read is not doing that for you.
I assume that aio_read returns the number of bytes read (or -1 on error), so to fix you
probably need to
If an error condition is detected that prevents the read request from being enqueued, aio_read() returns -1 and sets errno to indicate the cause of the failure. Once the read operation has been successfully enqueued, an aio_error() and aio_return() function referencing the aiocb referred to by aiocbp must be used to determine its status and any error conditions, including those normally reported by read(). The request remains enqueued and consumes process and system resources until aio_return() is called.
It looks like you've started an async read, but started to use the results before they're ready. The point of async I/O is to allow I/O to run concurrently with any processing you have to do without spawning a thread to do it. You still have to wait for the I/O to actually complete.
I seems use `for` itn's good with aio, more over not good use superfluous loops.
usually I did it by this way, perhaps it's so funky use for loop with aio?