title: Define TCP socket options
body: <p>I'm trying to write a small http downloader package which can allow to control tcp socket options while creating, and i really stuck with possibility of definition socket options. 
  As far as I understand, in the version 1.11 in package <strong>net</strong> struct <em>Dialer</em> was added interface <strong>Control</strong> which should allow to define such options, but i cannot find any valid example regarding usage in the context i'm trying to implement.</p>
  
  <pre><code>dialer := &amp;net.Dialer{
      Timeout:       5 * time.Second,
      Deadline:      time.Time{},
      LocalAddr:     nil,
      DualStack:     false,
      FallbackDelay: 0,
      KeepAlive:     0,
      Resolver:      nil,
      Control: controlOnConnectionSetup,
  }
  // set client
  client := http.Client{
      Transport:     &amp;http.Transport{
          Proxy: nil,
          DialContext: func(ctx context.Context, network, addr string) (net.Conn, error) {
              return dialer.DialContext(ctx, "tcp", addr)
          },
          Dial:                   nil,
          DialTLS:                nil,
          TLSClientConfig:        nil,
          TLSHandshakeTimeout:    0,
          DisableKeepAlives:      false,
          DisableCompression:     false,
          MaxIdleConns:           0,
          MaxIdleConnsPerHost:    0,
          MaxConnsPerHost:        0,
          IdleConnTimeout:        0,
          ResponseHeaderTimeout:  0,
          ExpectContinueTimeout:  0,
          TLSNextProto:           nil,
          ProxyConnectHeader:     nil,
          MaxResponseHeaderBytes: 0,
      },
      CheckRedirect: nil,
      Jar:           nil,
      Timeout:       3,
  }
  </code></pre>
  
  <p>And the code of <em>cotrol</em> function (which is not working, it's just copy from example where i cannot find any mentions of <em>fd</em> variable):</p>
  
  <pre><code>func controlOnConnectionSetup(network string, address string, c syscall.RawConn) error {
  var operr error
  fn := func(s uintptr) {
      handle := syscall.Handle(fd)
      operr = syscall.SetsockoptInt(handle, syscall.SOL_SOCKET, syscall.SO_REUSEADDR, 1)
      if operr != nil {
          return
      }
  }
  if err := c.Control(fn); err != nil {
      return err
  }
  if operr != nil {
      return operr
  }
  return nil
  </code></pre>
  
  <p>}</p>
  
  <p>I would be really appreciated if anyone can tell me what am i doing wrong or at least provide example on how to control socket parameters in tcp connection.</p>