-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Closed
Labels
Description
What version of Go are you using (go version
)?
$ go version go version go1.16.2 windows/amd64
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env
)?
go env
Output
$ go env set GO111MODULE= set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\vbox\AppData\Local\go-build set GOENV=C:\Users\vbox\AppData\Roaming\go\env set GOEXE=.exe set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GOMODCACHE=C:\Users\vbox\go\pkg\mod set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=C:\Users\vbox\go set GOPRIVATE= set GOPROXY=https://proxy.golang.org,direct set GOROOT=C:\Program Files\Go set GOSUMDB=sum.golang.org set GOTMPDIR= set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64 set GOVCS= set GOVERSION=go1.16.2 set GCCGO=gccgo set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD=NUL set CGO_CFLAGS=-g -O2 set CGO_CPPFLAGS= set CGO_CXXFLAGS=-g -O2 set CGO_FFLAGS=-g -O2 set CGO_LDFLAGS=-g -O2 set PKG_CONFIG=pkg-config set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\vbox\AppData\Local\Temp\go-build406273817=/tmp/go-build -gno-record-gcc-switches
What did you do?
please try the following reproducer
package main
import (
"fmt"
"net"
"os"
)
func main() {
listen, err := net.Listen("tcp", ":2024")
if err != nil {
fmt.Printf("Listen error: %s\n", err)
os.Exit(1)
} else {
fmt.Printf("Listening tcp ...\n")
}
go func() {
_, err := net.Listen("tcp4", ":2024")
if err != nil {
fmt.Printf("Listen tcp4 error: %v\n", err)
return
}
fmt.Printf("Listen on tcp4 should fail!\n")
}()
coon, err := listen.Accept()
if err != nil {
fmt.Println("Accept() err=", err)
} else {
fmt.Printf("Accept() conn=%v\n client's remote address=%v\n", coon, coon.RemoteAddr())
}
}
What did you expect to see?
On Linux and macOS I have this output:
$ go run main.go
Listening tcp ...
Listen tcp4 error: listen tcp4 :2024: bind: address already in use
What did you see instead?
On Windows I have this output:
Z:\>go run main.go
Listening tcp ...
Listen on tcp4 should fail!