github.com/sagernet/tfo-go@v0.0.0-20231209031829-7b5343ac1dc6/sockopt_linux.go (about)

     1  package tfo
     2  
     3  import "golang.org/x/sys/unix"
     4  
     5  // TCPFastopenQueueLength is the maximum number of total pending TFO connection requests,
     6  // see https://datatracker.ietf.org/doc/html/rfc7413#section-5.1 for why this limit exists.
     7  // The current value aligns with Go std's listen(2) backlog (4096, as of the current version).
     8  //
     9  // Deprecated: This constant is no longer used in this module and will be removed in v3.
    10  const TCPFastopenQueueLength = 4096
    11  
    12  func setTFOListener(fd uintptr) error {
    13  	return setTFOListenerWithBacklog(fd, defaultBacklog)
    14  }
    15  
    16  func setTFOListenerWithBacklog(fd uintptr, backlog int) error {
    17  	return setTFO(int(fd), backlog)
    18  }
    19  
    20  func setTFODialer(fd uintptr) error {
    21  	return unix.SetsockoptInt(int(fd), unix.IPPROTO_TCP, unix.TCP_FASTOPEN_CONNECT, 1)
    22  }