]> Cypherpunks.ru repositories - gostls13.git/blob - src/net/main_windows_test.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / src / net / main_windows_test.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 net
6
7 import "internal/poll"
8
9 var (
10         // Placeholders for saving original socket system calls.
11         origWSASocket   = wsaSocketFunc
12         origClosesocket = poll.CloseFunc
13         origConnect     = connectFunc
14         origConnectEx   = poll.ConnectExFunc
15         origListen      = listenFunc
16         origAccept      = poll.AcceptFunc
17 )
18
19 func installTestHooks() {
20         wsaSocketFunc = sw.WSASocket
21         poll.CloseFunc = sw.Closesocket
22         connectFunc = sw.Connect
23         poll.ConnectExFunc = sw.ConnectEx
24         listenFunc = sw.Listen
25         poll.AcceptFunc = sw.AcceptEx
26 }
27
28 func uninstallTestHooks() {
29         wsaSocketFunc = origWSASocket
30         poll.CloseFunc = origClosesocket
31         connectFunc = origConnect
32         poll.ConnectExFunc = origConnectEx
33         listenFunc = origListen
34         poll.AcceptFunc = origAccept
35 }
36
37 // forceCloseSockets must be called only from TestMain.
38 func forceCloseSockets() {
39         for s := range sw.Sockets() {
40                 poll.CloseFunc(s)
41         }
42 }