Source file
src/net/main_windows_test.go
1
2
3
4
5 package net
6
7 import "internal/poll"
8
9 var (
10
11 origSocket = socketFunc
12 origWSASocket = wsaSocketFunc
13 origClosesocket = poll.CloseFunc
14 origConnect = connectFunc
15 origConnectEx = poll.ConnectExFunc
16 origListen = listenFunc
17 origAccept = poll.AcceptFunc
18 )
19
20 func installTestHooks() {
21 socketFunc = sw.Socket
22 wsaSocketFunc = sw.WSASocket
23 poll.CloseFunc = sw.Closesocket
24 connectFunc = sw.Connect
25 poll.ConnectExFunc = sw.ConnectEx
26 listenFunc = sw.Listen
27 poll.AcceptFunc = sw.AcceptEx
28 }
29
30 func uninstallTestHooks() {
31 socketFunc = origSocket
32 wsaSocketFunc = origWSASocket
33 poll.CloseFunc = origClosesocket
34 connectFunc = origConnect
35 poll.ConnectExFunc = origConnectEx
36 listenFunc = origListen
37 poll.AcceptFunc = origAccept
38 }
39
40
41 func forceCloseSockets() {
42 for s := range sw.Sockets() {
43 poll.CloseFunc(s)
44 }
45 }
46
View as plain text