简体   繁体   English

Linux 上的异​​步套接字发送

[英]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 ?当异步套接字上的发送返回 EAGAIN 时,这是否意味着:当前调用刚刚成功排队,或者由于系统仍在处理先前的发送而什么也没做?

Thank you in advance.先感谢您。

From man 2 send :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. POSIX.1-2001 允许在这种情况下返回任一错误,并且不要求此常量 [EAGAIN EWOULDBLOCK] 具有相同的值,因此可移植应用程序应检查这两种可能性。

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.所以,我认为EAGAIN意思是: 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. PS 实际上,看起来呼叫失败并且什么也没做。

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.当您获得返回值 -1 和 errno=EAGAIN 时,没有发送任何内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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