-
-
Save slingamn/3b0f81169de6578c732ec279828c4866 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "net" | |
import "time" | |
const ( | |
protocol = "tcp" | |
addr = ":6502" | |
) | |
func main() { | |
listener, err := net.Listen(protocol, addr) | |
if err != nil { | |
panic(err) | |
} | |
go func() { | |
for { | |
c, err := listener.Accept() | |
if err != nil { | |
return | |
} | |
c.Close() | |
} | |
}() | |
// trigger the race by giving the above goroutine time to start | |
time.Sleep(time.Second) | |
listener.Close() | |
_, err = net.Listen(protocol, addr) | |
if err != nil { | |
panic(err) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment