简体   繁体   中英

Asynchronous socket send on Linux

When send on an asynchronous socket returns EAGAIN, does that mean : that the current call has just been successfully queued or that nothing was done because the system is still processing a previous send ?

Thank you in advance.

From man 2 send :

The socket is marked nonblocking and the requested operation would block. POSIX.1-2001 allows either error to be returned for this case, and does not require this constants [EAGAIN EWOULDBLOCK] to have the same value, so a portable application should check for both possibilities.

So, I think EAGAIN means: be careful, the message did not fit into send buffer, this call would be blocked in normal (blocking) mode. Use select(2) to determine whether you can send more data. be careful, the message did not fit into send buffer, this call would be blocked in normal (blocking) mode. Use select(2) to determine whether you can send more data.

PS Actually, looks like the call failed and nothing was done.

Nothing was done.

If something is done, the return value tells you how many characters were sent. As you get the return value -1 and errno=EAGAIN, nothing was sent.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM