Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: Windows not support Bind for a raw/tcp socket #63807

Closed
lysShub opened this issue Oct 29, 2023 · 2 comments
Closed

net: Windows not support Bind for a raw/tcp socket #63807

lysShub opened this issue Oct 29, 2023 · 2 comments

Comments

@lysShub
Copy link

lysShub commented Oct 29, 2023

What version of Go are you using (go version)?

$ go version
go version go1.21.3 windows/amd64

Does this issue reproduce with the latest release?

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\lys\AppData\Local\go-build
set GOENV=C:\Users\lys\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=D:\gopath\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=D:\gopath
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.21.3
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config

What did you do?

package main

import "net"

func main(){
        conn, err := net.ListenIP("ip4:tcp", &net.IPAddr{IP: net.IPv4(0, 0, 0, 0)})
        if err != nil {
	        panic(err)
        }
        defer conn.Close()
}

What did you expect to see?

no error

What did you see instead?

panic: listen ip4:tcp 0.0.0.0: bind: An invalid argument was supplied.

goroutine 1 [running]:
main.main()
        D:/OneDrive/code/go/atest/main.go:27 +0x155
exit status 2
@lysShub
Copy link
Author

lysShub commented Oct 29, 2023

Windows not support Bind for a raw/tcp socket, ref

golang will call it https://github.com/golang/go/blob/go1.21.3/src/net/sock_posix.go#L140

@seankhliao
Copy link
Member

Given that windows doesn't support it, I don't think there's anything for Go to do.

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Oct 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants