<commit_before>// Copyright 2014 <NAME>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package tcp

import (
	"errors"
	"net"
	"os"

	"github.com/mikioh/netreflect"
	"github.com/mikioh/tcpopt"
)

var (
	errOpNoSupport    = errors.New("operation not supported")
	errBufferTooShort = errors.New("buffer too short")

	_ net.Conn = &Conn{}
)

// A Conn represents a network endpoint that uses TCP connection.
// It allows to set non-portable, platform-dependent TCP-level socket
// options.
type Conn struct {
	net.Conn
	s uintptr // socket descriptor for avoding data race
}

// SetOption sets a socket option.
func (c *Conn) SetOption(o tcpopt.Option) error {
	b, err := o.Marshal()
	if err != nil {
		return &net.OpError{Op: "set", Net: c.LocalAddr().Network(), Source: nil, Addr: c.LocalAddr(), Err: err}
	}
	if err := setsockopt(c.s, o.Level(), o.Name(), b); err != nil {
		return &net.OpError{Op: "set", Net: c.LocalAddr().Network(), Source: nil, Addr: c.LocalAddr(), Err: os.NewSyscallError("setsockopt", err)}
	}
	return nil
}

// Option returns a socket option.
func (c *Conn) Option(level, name int, b []byte) (tcpopt.Option, error) {
	if len(b) == 0 {
		return nil, errBufferTooShort
	}
	if err := getsockopt(c.s, level, name, b); err != nil {
		return nil, &net.OpError{Op: "get", Net: c.LocalAddr().Network(), Source: nil, Addr: c.LocalAddr(), Err: os.NewSyscallError("getsockopt", err)}
	}
	o, err := tcpopt.Parse(level, name, b)
	if err != nil {
		return nil, &net.OpError{Op: "get", Net: c.LocalAddr().Network(), Source: nil, Addr: c.LocalAddr(), Err: err}
	}
	return o, nil
}<commit_msg>tcp: tweak comment<commit_after>// Copyright 2014 <NAME>. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package tcp

import (
	"errors"
	"net"
	"os"

	"github.com/mikioh/netreflect"
	"github.com/mikioh/tcpopt"
)

var (
	errOpNoSupport    = errors.New("operation not supported")
	errBufferTooShort = errors.New("buffer too short")

	_ net.Conn = &Conn{}
)

// A Conn represents a network endpoint that uses TCP connection.
// It allows to set non-portable, platform-dependent TCP-level socket
// options.
type Conn struct {
	net.Conn
	s uintptr // socket descriptor for configuring options
}

// SetOption sets a socket option.
func (c *Conn) SetOption(o tcpopt.Option) error {
	b, err := o.Marshal()
	if err != nil {
		return &net.OpError{Op: "set", Net: c.LocalAddr().Network(), Source: nil, Addr: c.LocalAddr(), Err: err}
	}
	if err := setsockopt(c.s, o.Level(), o.Name(), b); err != nil {
		return &net.OpError{Op: "set", Net: c.LocalAddr().Network(), Source: nil, Addr: c.LocalAddr(), Err: os.NewSyscallError("setsockopt", err)}
	}
	return nil
}

// Option returns a socket option.
func (c *Conn) Option(level, name int, b []byte) (tcpopt.Option, error) {
	if len(b) == 0 {
		return nil, errBufferTooShort
	}
	if err := getsockopt(c.s, level, name, b); err != nil {
		return nil, &net.OpError{Op: "get", Net: c.LocalAddr().Network(), Source: nil, Addr: c.LocalAddr(), Err: os.NewSyscallError("getsockopt", err)}
	}
	o, err := tcpopt.Parse(level, name, b)
	if err != nil {
		return nil, &net.OpError{Op: "get", Net: c.LocalAddr().Network(), Source: nil, Addr: c.LocalAddr(), Err: err}
	}
	return o, nil
}
{'fraction_non_alphanumeric': 0.16067716067716067, 'fraction_numerical': 0.00297000297000297, 'mean_word_length': 3.9239766081871346, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6654495', 'n_tokens_mistral': 1220, 'n_tokens_neox': 1179, 'n_words': 383}