mirror of
https://github.com/gospider007/requests.git
synced 2025-12-24 13:57:52 +08:00
18 lines
611 B
Go
18 lines
611 B
Go
//go:build linux
|
|
|
|
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_CORK, 1)
|
|
syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_NODELAY, 0)
|
|
syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1) // 启用地址重用
|
|
syscall.SetsockoptLinger(int(fd), syscall.SOL_SOCKET, syscall.SO_LINGER, &syscall.Linger{Onoff: 1, Linger: 0})
|
|
syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, 1)
|
|
})
|
|
}
|