mirror of
https://github.com/gospider007/requests.git
synced 2025-12-24 13:57:52 +08:00
15 lines
416 B
Go
15 lines
416 B
Go
//go:build darwin
|
||
|
||
package requests
|
||
|
||
import (
|
||
"syscall"
|
||
)
|
||
|
||
func Control(network, address string, c syscall.RawConn) error {
|
||
return c.Control(func(fd uintptr) {
|
||
syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_NODELAY, 1) //0 表示关闭 TCP_NODELAY,即开启 Nagle 算法。
|
||
syscall.SetsockoptLinger(int(fd), syscall.SOL_SOCKET, syscall.SO_LINGER, &syscall.Linger{Onoff: 1, Linger: 0})
|
||
})
|
||
}
|