Is it possible to find out the number of bytes written with `conn.AsyncWrite()`?
Please fill out the following system information before opening an issue: OS: Ubuntu 20.04.5 LTS Go version: go1.19.3 linux/amd64 gnet version: 2.1.1
What is your question about gnet?
conn.Write() returns the number of bytes written.
Is it possible to find out the number of bytes written with conn.AsyncWrite()?
Not supported yet, but I think it's reasonable to implement this feature.
Can I help with this ? But I reckon that since this library has been used for a long time, so change
AsyncWrite(buf []byte, callback AsyncCallback) (err error) into something like AsyncWrite(buf []byte, callback AsyncCallback) (length int, err error) would break things right?
AsyncWrite() writes bytes asynchronously, so I don't think that it can return the number of written bytes synchronously. Furthermore, there is a promising buffer management inside gnet that ensures all bytes will be handled properly, which means that once you call Write() or AsyncWrite(), you can assume that your data will be sent to the remote peer eventually if no errors are returned from those methods. You can deem that as a guarantee by gnet. That is, you only need to check the returned errors and callback returned errors of Write() and AsyncWrite(), and if all errors are nil, your data is guaranteed to be sent successfully.