套接字配置中的 TCP 重传 [英] TCP Retransmissions in Socket Configuration

查看:51
本文介绍了套接字配置中的 TCP 重传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 C++ 中用作套接字(Winsock2 for windows 和 socket.h for linux)有没有办法将 TCP 重传配置为比默认值少或多?我的意思是:我知道有注册表项:

I'm using as socket in C++ (Winsock2 for windows and socket.h for linux) is there a way to configure the TCP retransmissions to be less or more than the default? I mean: I know there is the registry key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
TCPMaxDataRetransmissions

我可以为所有应用程序配置它,但我只想将应用程序中的套接字配置为默认值以外的套接字.

that there I can configure it for all applications, but I want to configure only the socket in my application to be other than the default.

推荐答案

我还没试过这个,但我知道有一个 TCP_MAXRT 选项可以设置.刚刚在include目录中快速搜索了一下,我看到它在Windows中的ws2ipdef.h中定义.

I haven't tried this out, but I know there is a TCP_MAXRT option that you can set. Just did a quick search in the include directory, and I see it defined in ws2ipdef.h in Windows.

int maxrt = 10;
setsockopt(sock, IPPROTO_TCP, TCP_MAXRT, &maxrt, sizeof(maxrt));

这篇关于套接字配置中的 TCP 重传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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