在solaris 中套接字错误EINPROGRESS 的可能原因是什么? [英] What are possible reason for socket error EINPROGRESS in solaris?

查看:35
本文介绍了在solaris 中套接字错误EINPROGRESS 的可能原因是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Solaris 中套接字错误 EINPROGRESS 的可能原因是什么?我们如何检查根本原因?

What are possible reason for socket error EINPROGRESS in Solaris? How we can check the root cause?

tcp api 是:连接

tcp api is : connect

推荐答案

您有一个非阻塞套接字,并且正在其中调用 connect().由于 connect() 需要发生 3 次握手(所以是网络往返),它要么阻止等待阻塞套接字中的 SYN-ACK,要么给你一些指示它没有成功但在非阻塞套接字中.通常,非阻塞套接字返回 EAGAIN/EWOULDBLOCK 以告诉您它们无法进行,您应该再试一次:这不完全是您的情况,connect() 在没有免费的临时端口告诉你你应该稍后再试;所以非阻塞连接还有另一个错误:EINPROGRESS,它告诉你操作正在进行中,你应该稍后检查它的状态.

You have a non-blocking socket and you are calling connect() in it. Since connect() needs the 3-way handshake to happen (so a network roundtrip), it either blocks waiting for the SYN-ACK in blocking sockets, or gives you some indication that it hasn't succeded yet in non-blocking sockets. Normally, non-blocking sockets return EAGAIN/EWOULDBLOCK to tell you that they couldn't progress and you should try again: this is not exactly your case, connect() returns EAGAIN/EWOULDBLOCK when there are no free ephemeral ports to tell you that you should try again later; so there is another error for non-blocking connect: EINPROGRESS, which tells you that the operation is in progress and you should check its status later.

为了稍后检查状态,套接字将准备好可写,因此您可以使用 select()/poll()/... 来测试它,之后您必须getsockopt(...SO_ERROR...) 来获取 connect() 操作的成功/失败状态.

To check the status later, the socket will become ready for writability, so you can use select()/poll()/... to test for that, after which you'll have to getsockopt(...SO_ERROR...) to get the success/failure status of your connect() operation.

这篇关于在solaris 中套接字错误EINPROGRESS 的可能原因是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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