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: Dial("tcp", ":port") fails on Windows #15216

Closed
taylorchu opened this issue Apr 9, 2016 · 4 comments
Closed

net: Dial("tcp", ":port") fails on Windows #15216

taylorchu opened this issue Apr 9, 2016 · 4 comments

Comments

@taylorchu
Copy link

According to the package doc, address without host specified should be allowed, e.g. Dial("tcp", ":80"). But an error connectex: The requested address is not valid in its context is returned on windows 10.

Please answer these questions before submitting your issue. Thanks!

  1. What version of Go are you using (go version)?
$ go version
go version go1.6 windows/amd64
  1. What operating system and processor architecture are you using (go env)?
$ go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:/Users/taylorchu/go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GO15VENDOREXPERIMENT=1
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
  1. What did you do?

    http://play.golang.org/p/G8gttmZyvA

  2. What did you expect to see?

net.Dial without specifying host should cause no error.

  1. What did you see instead?

connectex: The requested address is not valid in its context.

@bradfitz
Copy link
Contributor

bradfitz commented Apr 9, 2016

Wow, interesting. I didn't know that even worked on Linux!

$ cat dial.go 
package main

import (
        "log"
        "net"
)

func main() {
        c, err := net.Dial("tcp", ":8080")
        log.Printf("c, err = %#T, %v", c, err)
}

$ go run dial.go 
2016/04/09 23:27:30 c, err = *net.TCPConn, <nil>

So does it mean localhost? Should we keep this working and add tests so we don't regress and it works on Windows? I guess so.

/cc @mikioh @alexbrainman @ianlancetaylor

@bradfitz bradfitz changed the title net.Dial fails if host is missing on windows 10 net: Dial("tcp", ":port") fails on Windows Apr 9, 2016
@bradfitz bradfitz added this to the Go1.7 milestone Apr 9, 2016
@mikioh
Copy link
Contributor

mikioh commented Apr 10, 2016

This is a duplicate of #6290. Still not sure whether a wildcard address, "0.0.0.0", "::" or "", means the entire IP addressing space or any available address on the routing instance.

@mikioh mikioh closed this as completed Apr 10, 2016
@alexbrainman
Copy link
Member

What @mikioh said.

Alex

@muly
Copy link

muly commented Mar 13, 2017

#6290 is marked as closed, but I see some issue on Windows when using the redis.Dial. not sure if my error has to do anything with the go directly, but wanted to post here if it helps anyone. I reported the issue in the redigo repo too.

working
redis.Dial("tcp", "localhost:6379")

NOT working
redis.Dial("tcp", ":6379")
error message: dial tcp :6379: connectex: The requested address is not valid in its context.

My environment:

$ go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\gows
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants