title: Get syscall.Handle from a Go *net.UDPConn on Windows?
body: <p>How do I obtain the underlying <code>syscall.Handle</code> for a <code>*net.UDPConn</code> on Windows? I want this handle to set the <code>IP_MULTICAST_TTL</code> via <code>syscall.SetsockoptInt</code>. On Linux I do the following:</p>
  
  <pre><code>func setTTL(conn *net.UDPConn, ttl int) error {
      f, err := conn.File()
      if err != nil {
          return err
      }
      defer f.Close()
      fd := int(f.Fd())
      return syscall.SetsockoptInt(fd, syscall.SOL_IP, syscall.IP_MULTICAST_TTL, ttl)
  }
  </code></pre>
  
  <p>But on Windows, the implicit <code>dup</code> inside <code>*net.UDPConn</code>'s <code>File()</code> fails with:</p>
  
  <blockquote>
    <p>04:24:49 main.go:150: dup: not supported by windows</p>
  </blockquote>
  
  <p>And in the source code is marked as  a to-do. How can I get this handle? Is there some other way to set the TTL if not?</p>
  
  <h1>Update0</h1>
  
  <p>I've submitted the shortcomings to the Go issue tracker:</p>
  
  <ul>
  <li><a href="http://code.google.com/p/go/issues/detail?id=3826" rel="nofollow">SetTTL for *net.UDPConn</a></li>
  <li><a href="http://code.google.com/p/go/issues/detail?id=3827" rel="nofollow">Implement dup for netFD on Windows</a></li>
  </ul>