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.
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
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
28 func uninstallTestHooks() {
29 wsaSocketFunc = origWSASocket
30 poll.CloseFunc = origClosesocket
31 connectFunc = origConnect
32 poll.ConnectExFunc = origConnectEx
33 listenFunc = origListen
34 poll.AcceptFunc = origAccept
37 // forceCloseSockets must be called only from TestMain.
38 func forceCloseSockets() {
39 for s := range sw.Sockets() {