Home | History | Annotate | Download | only in net
      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 var (
      8 	// Placeholders for saving original socket system calls.
      9 	origSocket      = socketFunc
     10 	origClosesocket = closeFunc
     11 	origConnect     = connectFunc
     12 	origConnectEx   = connectExFunc
     13 	origListen      = listenFunc
     14 )
     15 
     16 func installTestHooks() {
     17 	socketFunc = sw.Socket
     18 	closeFunc = sw.Closesocket
     19 	connectFunc = sw.Connect
     20 	connectExFunc = sw.ConnectEx
     21 	listenFunc = sw.Listen
     22 }
     23 
     24 func uninstallTestHooks() {
     25 	socketFunc = origSocket
     26 	closeFunc = origClosesocket
     27 	connectFunc = origConnect
     28 	connectExFunc = origConnectEx
     29 	listenFunc = origListen
     30 }
     31 
     32 func forceCloseSockets() {
     33 	for s := range sw.Sockets() {
     34 		closeFunc(s)
     35 	}
     36 }
     37