gpt4 book ai didi

objective-c - 如何在iPhone上增加TCP "receive window"

转载 作者:行者123 更新时间:2023-11-30 15:57:20 27 4
gpt4 key购买 nike

我似乎只能接收最大 8k 字节的流大小。之后就废了。我怎样才能放大这个?谢谢

    host = gethostbyname("xxx"); 

memcpy(&(sin.sin_addr), host->h_addr, host->h_length);
sin.sin_family = host->h_addrtype;
sin.sin_port = htons(4000);

s = socket(AF_INET, SOCK_STREAM, 0);
hConnect = connect(s, (struct sockaddr*)&sin, sizeof(sin));


char buffer[8000];// tried setting higher, doesn't change anything
memset(buffer, '\0', 8000);
recv(s, buffer, sizeof(buffer), 0); // <------8k max, need 64k

最佳答案

下面是读取 64KiB 的代码:

char* buffer = malloc(65536);
int len = 0;
while (len < 65536)
{
int rc = recv(s, buffer + len, 65536 - len, 0);
if (rc == 0)
break; // connection closed
else if (rc > 0)
len += rc;
else if (errno != EINTR)
{
// handle error
break;
}
}

关于objective-c - 如何在iPhone上增加TCP "receive window",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10574887/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com