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

Comments

Projects
None yet
6 participants
@taylorchu
Copy link

commented Apr 9, 2016

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

This comment has been minimized.

Copy link
Member

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

@bradfitz bradfitz added the OS-Windows label Apr 9, 2016

@mikioh

This comment has been minimized.

Copy link
Contributor

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 Apr 10, 2016

@alexbrainman

This comment has been minimized.

Copy link
Member

commented Apr 10, 2016

What @mikioh said.

Alex

@muly

This comment has been minimized.

Copy link

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

@golang golang locked and limited conversation to collaborators Mar 13, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.