Skip to content

Commit

Permalink
use sys/unix instead of syscall
Browse files Browse the repository at this point in the history
Suggestion from:
#1395 (comment)
  • Loading branch information
xiaokangwang committed Apr 28, 2022
1 parent 8c0a04c commit bceda7a
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions transport/internet/sockopt_darwin.go
Expand Up @@ -5,20 +5,17 @@ import (
)

const (
// TCP_FASTOPEN is the socket option on darwin for TCP fast open.
TCP_FASTOPEN = 0x105 // nolint: golint,stylecheck
// TCP_FASTOPEN_SERVER is the value to enable TCP fast open on darwin for server connections.
TCP_FASTOPEN_SERVER = 0x01 // nolint: golint,stylecheck
// TCP_FASTOPEN_CLIENT is the value to enable TCP fast open on darwin for client connections.
TCP_FASTOPEN_CLIENT = 0x02 // nolint: revive,stylecheck
TCP_KEEPINTVL = 0x101 // nolint: golint,stylecheck
)

func applyOutboundSocketOptions(network string, address string, fd uintptr, config *SocketConfig) error {
if isTCPSocket(network) {
switch config.Tfo {
case SocketConfig_Enable:
if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_FASTOPEN, unix.TCP_FASTOPEN_CLIENT); err != nil {
if err := unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_FASTOPEN, TCP_FASTOPEN_CLIENT); err != nil {
return err
}
case SocketConfig_Disable:
Expand Down

0 comments on commit bceda7a

Please sign in to comment.