Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pconnect_n超时问题 #201

Closed
airx opened this issue Jan 10, 2020 · 16 comments
Closed

pconnect_n超时问题 #201

airx opened this issue Jan 10, 2020 · 16 comments

Comments

@airx
Copy link

airx commented Jan 10, 2020

int pconnect_n(const char* hostname, u_short port,
const std::chrono::microseconds& wtimeout, u_short local_port = 0);
这个运行,我发现超时是两倍wtimeout,设一秒,两秒报超时。
mac上测试的。

@halx99
Copy link
Member

halx99 commented Jan 10, 2020

你是传的域名吗

@halx99
Copy link
Member

halx99 commented Jan 10, 2020

看看域名是不是返回了多个ip地址

@airx
Copy link
Author

airx commented Jan 10, 2020

看看域名是不是返回了多个ip地址

IP地址
image

@halx99
Copy link
Member

halx99 commented Jan 11, 2020

image

除非这里select执行两次,否则,时间不会是双倍

@airx
Copy link
Author

airx commented Jan 11, 2020

xpconnect_n和pconnect_n执行了两次select;connect_n执行了一次select。
xpconnect_n,pconnect_n和connect_n各自含义,好像你说的是ipv4和ipv6,具体用哪个好点呢,或者说无脑用哪个就对了,不用考虑什么情况。

@halx99
Copy link
Member

halx99 commented Jan 11, 2020

image

xpconnect你看看这个list, 会不会有两个

@halx99
Copy link
Member

halx99 commented Jan 11, 2020

pconnect_n是直接调用connect_n不会进行域名解析

@airx
Copy link
Author

airx commented Jan 11, 2020

image

xpconnect你看看这个list, 会不会有两个

对,是2个,如果换成域名www.baidu.com,就变成4个了

@halx99
Copy link
Member

halx99 commented Jan 11, 2020

擦,这么神奇,直接写ip地址,尽然还能有两个

@airx
Copy link
Author

airx commented Jan 11, 2020

擦,这么神奇,直接写ip地址,尽然还能有两个

嗯,你试试呢

@halx99
Copy link
Member

halx99 commented Jan 11, 2020

我手上没有mac电脑,我win10上测试超时正常

@halx99
Copy link
Member

halx99 commented Jan 11, 2020

我用travis ci跑了下,还真是:
image

@halx99
Copy link
Member

halx99 commented Jan 11, 2020

我找到问题所在了

@halx99 halx99 closed this as completed in 4d39a3d Jan 11, 2020
@halx99
Copy link
Member

halx99 commented Jan 11, 2020

修复了:
image

@airx
Copy link
Author

airx commented Jan 12, 2020

我找到问题所在了

这个会影响udp吗?

@halx99
Copy link
Member

halx99 commented Jan 12, 2020

不会

@halx99 halx99 added this to the 3.31.2 milestone Jan 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants