1
lcdtyph 2020-07-27 05:56:27 +08:00 via iPhone
这个 opt 的 level 是 IPPROTO_TCP,不是 SOL_SOCKET
setsockopt 是有返回值的,最好检查一下 |
2
holinhot OP |
3
holinhot OP @lcdtyph
返回是 0 Type "help", "copyright", "credits" or "license" for more information. >>> from socket import socket, IPPROTO_TCP, TCP_WINDOW_CLAMP, AF_INET, SOCK_STREAM, SOL_TCP >>> >>> s = socket(AF_INET, SOCK_STREAM) >>> >>> s.setsockopt(IPPROTO_TCP, TCP_WINDOW_CLAMP, 0) >>> >>> s.getsockopt(IPPROTO_TCP, TCP_WINDOW_CLAMP) 0 23:15:01.484753 IP 127.0.0.1.http > 127.0.0.1.62668: Flags [S.], seq 2645892072, ack 98484869, win 29200, options [mss 1460,nop,nop,sackOK,nop,wscale 7], length 0 23:15:01.521700 IP 127.0.0.1.http > 127.0.0.1.62668: Flags [.], ack 76, win 229, length 0 抓包还是不起作用 |
4
holinhot OP @lcdtyph
不知道什么情况了 >>> s.setsockopt(IPPROTO_TCP, TCP_WINDOW_CLAMP, 1000) >>> s.getsockopt(IPPROTO_TCP, TCP_WINDOW_CLAMP) 1152 >>> >>> s.setsockopt(IPPROTO_TCP, TCP_WINDOW_CLAMP, 500) >>> s.getsockopt(IPPROTO_TCP, TCP_WINDOW_CLAMP) 1152 >>> s.setsockopt(IPPROTO_TCP, TCP_WINDOW_CLAMP, 100) >>> s.getsockopt(IPPROTO_TCP, TCP_WINDOW_CLAMP) 1152 >>> s.setsockopt(IPPROTO_TCP, TCP_WINDOW_CLAMP, 0) >>> s.getsockopt(IPPROTO_TCP, TCP_WINDOW_CLAMP) 0 |
5
lcdtyph 2020-07-27 07:35:17 +08:00 via iPhone
|
6
lcdtyph 2020-07-27 07:36:45 +08:00 via iPhone
|
8
holinhot OP @holinhot if (!val) {
if (sk->sk_state != TCP_CLOSE) { err = -EINVAL; break; } tp->window_clamp = 0; } else tp->window_clamp = val < SOCK_MIN_RCVBUF / 2 ? SOCK_MIN_RCVBUF / 2 : val; break; 2.3 if (val==0) { if (sk->state != TCP_CLOSE) { err = -EINVAL; break; } tp->window_clamp = 0; } else { tp->window_clamp = val<SOCK_MIN_RCVBUF/2 ? SOCK_MIN_SNDBUF : val; } break; |