OSDN Git Service

new repo
[bytom/vapor.git] / vendor / golang.org / x / net / internal / nettest / helper_windows.go
1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package nettest
6
7 import (
8         "fmt"
9         "runtime"
10         "syscall"
11 )
12
13 func maxOpenFiles() int {
14         return 4 * defaultMaxOpenFiles /* actually it's 16581375 */
15 }
16
17 func supportsRawIPSocket() (string, bool) {
18         // From http://msdn.microsoft.com/en-us/library/windows/desktop/ms740548.aspx:
19         // Note: To use a socket of type SOCK_RAW requires administrative privileges.
20         // Users running Winsock applications that use raw sockets must be a member of
21         // the Administrators group on the local computer, otherwise raw socket calls
22         // will fail with an error code of WSAEACCES. On Windows Vista and later, access
23         // for raw sockets is enforced at socket creation. In earlier versions of Windows,
24         // access for raw sockets is enforced during other socket operations.
25         s, err := syscall.Socket(syscall.AF_INET, syscall.SOCK_RAW, 0)
26         if err == syscall.WSAEACCES {
27                 return fmt.Sprintf("no access to raw socket allowed on %s", runtime.GOOS), false
28         }
29         if err != nil {
30                 return err.Error(), false
31         }
32         syscall.Closesocket(s)
33         return "", true
34 }
35
36 func supportsIPv6MulticastDeliveryOnLoopback() bool {
37         return true
38 }
39
40 func causesIPv6Crash() bool {
41         return false
42 }