如何更改TCP套接字是非阻塞的? [英] How do I change a TCP socket to be non-blocking?

查看:224
本文介绍了如何更改TCP套接字是非阻塞的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉毫瓦如何将TCP IP套接字转换成非阻塞插座。我知道的fcntl()函数,但我听说他们并不总是可靠的。

Please tell mw how to convert a TCP IP socket into NON Blocking socket. I am aware of the fcntl() function but I heard that they are not always reliable.

推荐答案

你是什么并不总是可靠是什么意思?如果系统中设置的插座非无阻塞成功,这将是非阻塞的。套接字操作将返回 EWOULDBLOCK ,如果他们将阻止需要阻止(例如,如果输出缓冲区已满,你打电话发/写过于频繁)。

What do you mean by "not always reliable"? If the system succeeds in setting your socket non non-blocking, it will be non-blocking. Socket operations will return EWOULDBLOCK if they would block need to block (e.g. if the output buffer is full and you're calling send/write too often).

与非阻塞调用时,这个论坛主题有几个好点。

这篇关于如何更改TCP套接字是非阻塞的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆