-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
I m not expert and I don t know, whether this belong to Proposals or Bugs, so sorry...
What version of Go are you using (go version)?
go version go1.18 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
set GO111MODULE=on set GOARCH=amd64 set GOBIN= set GOCACHE=C:\Users\matej\AppData\Local\go-build set GOENV=C:\Users\matej\AppData\Roaming\go\env set GOEXE=.exe set GOEXPERIMENT= set GOFLAGS= set GOHOSTARCH=amd64 set GOHOSTOS=windows set GOINSECURE= set GOMODCACHE=C:\Users\matej\go\pkg\mod set GONOPROXY= set GONOSUMDB= set GOOS=windows set GOPATH=C:\Users\matej\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.18 set GCCGO=gccgo set GOAMD64=v1 set AR=ar set CC=gcc set CXX=g++ set CGO_ENABLED=1 set GOMOD=C:\Users\matej\GolandProjects\bluetooth\go.mod set GOWORK= 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\matej\AppData\Local\Temp\go-build2316299000=/tmp/go-build -gno-record-gcc-switches
What did you do?
I wanted create bluetooth socket on windows and I found that, there is no SockaddrBth similar (eqivalent) to SOCKADDR_BTH:
package main
import "golang.org/x/sys/windows"
func main() {
sock, err := windows.Socket(windows.AF_BTH, windows.SOCK_STREAM, windows.BTHPROTO_RFCOMM)
if err != nil {
panic(err)
}
println(sock) // here is all right
//err = windows.Bind(sock,?)
//if err != nil {
// panic(err)
//}
//return
}
So I was trying to add own struct to vendor according above mention SOCKADDR_BTH
type SockaddrBth struct {
family uint16
BtAddr [6]byte
ServiceClassId GUID
Port uint16
}
func (sa *SockaddrBth) sockaddr() (unsafe.Pointer, int32, error) {
if sa.Port < 0 || sa.Port > 31 {
return nil, 0, syscall.EINVAL
}
sa.family = AF_BTH
p := (*[2]byte)(unsafe.Pointer(&sa.Port))
p[0] = byte(sa.Port >> 8)
p[1] = byte(sa.Port)
return unsafe.Pointer(sa), int32(unsafe.Sizeof(*sa)), nil
}
and run
package main
import (
"golang.org/x/sys/windows"
)
func main() {
...
sock, err := windows.Socket(windows.AF_BTH, windows.SOCK_STREAM, windows.BTHPROTO_RFCOMM)
if err != nil {
panic(err)
}
g, _ := windows.GenerateGUID()
s := &windows.SockaddrBth{
BtAddr: [6]byte{},
ServiceClassId: g,
Port: 1,
}
err = windows.Bind(sock, s)
if err != nil {
panic(err) //golang.org/x/sys/windows.WSAEFAULT (10014)
}
...
}
What did you expect to see?
no error
What did you see instead?
golang.org/x/sys/windows.WSAEFAULT (10014)
Metadata
Metadata
Assignees
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.