<commit_before>package aero

import (
	"net"
	"time"
)

const keepAlivePeriod = 3 * time.Minute

// Listener sets TCP keep-alive timeouts on accepted connections.
type Listener struct {
	*net.TCPListener
}

// Accept accepts incoming connections.
func (listener Listener) Accept() (net.Conn, error) {
	// Accept a new client.
	connection, err := listener.AcceptTCP()

	if err != nil {
		return nil, err
	}

	// Set keep-alive values based on the default values
	// found in the net/http TCP listener implementation.
	err = connection.SetKeepAlive(true)

	if err != nil {
		return nil, err
	}

	err = connection.SetKeepAlivePeriod(keepAlivePeriod)

	if err != nil {
		return nil, err
	}

	// Disable Nagle's algorithm to get lower latency.
	// NoDelay causes TCP packets to be sent immediately
	// when we call Write() instead of waiting to possibly
	// reduce the amount of packets. As Aero is fully aware
	// of the entire response data for most responses and only
	// causes a single Write() call, the delay should be disabled.
	err = connection.SetNoDelay(true)

	if err != nil {
		return nil, err
	}

	return connection, nil
}
<commit_msg>Accept default interval for TCP keep-alive<commit_after>package aero

import (
	"net"
	"time"
)

const keepAlivePeriod = 3 * time.Minute

// Listener sets TCP keep-alive timeouts on accepted connections.
type Listener struct {
	*net.TCPListener
}

// Accept accepts incoming connections.
func (listener Listener) Accept() (net.Conn, error) {
	// Accept a new client.
	connection, err := listener.AcceptTCP()

	if err != nil {
		return nil, err
	}

	// Set keep-alive values based on the default values
	// found in the net/http TCP listener implementation.
	err = connection.SetKeepAlive(true)

	if err != nil {
		return nil, err
	}

	// Ignore the error here because some systems do not allow
	// setting the TCP_USER_TIMEOUT socket option (issue #10).
	_ = connection.SetKeepAlivePeriod(keepAlivePeriod)

	// Disable Nagle's algorithm to get lower latency.
	// NoDelay causes TCP packets to be sent immediately
	// when we call Write() instead of waiting to possibly
	// reduce the amount of packets. As Aero is fully aware
	// of the entire response data for most responses and only
	// causes a single Write() call, the delay should be disabled.
	err = connection.SetNoDelay(true)

	if err != nil {
		return nil, err
	}

	return connection, nil
}

{'fraction_non_alphanumeric': 0.08771929824561403, 'fraction_numerical': 0.001670843776106934, 'mean_word_length': 3.4599627560521413, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2296368', 'n_tokens_mistral': 737, 'n_tokens_neox': 708, 'n_words': 295}