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("ip", ...) fails on Windows with "ConnectEx ip4: An invalid argument was specified" #6122

Closed
gopherbot opened this issue Aug 12, 2013 · 9 comments
Milestone

Comments

@gopherbot
Copy link

by jleimon:

DESCRIPTION

The following APIs:

  net.Dial("ip4", ...)
  net.Dial("ip6", ...)
  net.Dial("ip", ...) 

Are broken on Windows.


REPRODUCING THE PROBLEM

1. Build and run the program.

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


EXPECTED OUTPUT

TEST:  net.Dial("ip4:1", "127.0.0.1")  ... PASS


ACTUAL OUTPUT

TEST:  net.Dial("ip4:1", "127.0.0.1")  ... FAIL
  dial ip4 127.0.0.1: ConnectEx ip4: An invalid argument was supplied.
panic: dial ip4 127.0.0.1: ConnectEx ip4: An invalid argument was supplied.

goroutine 1 [running]:
main.main()
        c:/WORKSTATION/WORKSPACE/go_net_test/test_dial_ip4/test_dial_ip4.go:14 +0x118

goroutine 2 [runnable]:
runtime.MHeap_Scavenger()
        c:/go_src/src/pkg/runtime/mheap.c:443
runtime.goexit()
        c:/go_src/src/pkg/runtime/proc.c:1365

COMPILER

8g


OPERATING SYSTEM

Windows 7 Professional Service Pack 1 [Version 6.1.7601]


GO VERSION

go version devel +745f029d8e08 Mon Aug 12 13:47:18 2013 -0700 windows/386


OTHER NOTES

I have traced the go code to a call to oi.Submit (ConnectEx) that is failing, but I'm
not sure why. (See below)

Call Stack for  Dial(network, address string)

  ----> Dial(network, address string)
    ----> resolveAndDial(network, address, d.LocalAddr, d.deadline())
      | 
      | 
      ----> resolveAddr("dial", net, addr, deadline)
      ----> dial(net, addr, localAddr, ra, deadline)
        ----> dialIP(net, la, ra, deadline) [iprawsock_posix.go]
          ----> internetSocket(net, laddr.toAddr(), raddr.toAddr(), deadline, syscall.SOCK_RAW, proto, "dial", sockaddrToIP) [ipsock_posix.go]
            ----> socket(net, family, sotype, proto, ipv6only, la, ra, deadline, toAddr) [sock_posix.go]
              ----> fd.connect(ulsa, ursa) [fd_windows.go]
                ----> iosrv.ExecIO(&o, fd.wdeadline.value())  [fd_windows.go]
                  ----> oi.Submit() [fd_windows.go] (ConnectEx)
@robpike
Copy link
Contributor

robpike commented Aug 13, 2013

Comment 1:

Labels changed: added priority-later, os-windows, removed priority-triage.

Status changed to Accepted.

@mikioh
Copy link
Contributor

mikioh commented Aug 13, 2013

Comment 2:

Because ConnectEx supports only connection-oriented socket types, probably.

@alexbrainman
Copy link
Member

Comment 3:

I am sorry, mikioh, but I never used anything but tcp and udp. So you have to come up
with a plan here.
Alex

@mikioh
Copy link
Contributor

mikioh commented Aug 13, 2013

Comment 4:

Just sent: https://golang.org/cl/12843043/

@gopherbot
Copy link
Author

Comment 5 by jleimon:

I believe we will have to use connect, since ConnectEx is only supported on
connection-oriented sockets. (Ref:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms737606(v=vs.85).aspx) 
I've uploaded a simple (albeit poorly written) program that connects to a socket and
sends out an ICMP Ping packet to a server using connect() that you could use as a
reference. (see ping.c). For some reason the receive component does not work in the
program. The program will require linking in the WS2_32.lib library for the Winsock API.

Attachments:

  1. ping.c (6100 bytes)

@alexbrainman
Copy link
Member

Comment 6:

jleimon,
Did you try applying mikio's change https://golang.org/cl/12843043/ to see if
it fixes your problem? You don't need to change test files, just the fd_windows.go.
Thank you.
Alex

@gopherbot
Copy link
Author

Comment 7 by jleimon:

Alex,
It works on my box. Let's check it in!
Thanks,
John

@mikioh
Copy link
Contributor

mikioh commented Aug 23, 2013

Comment 8:

This issue was closed by revision 180da80.

Status changed to Fixed.

@mikioh
Copy link
Contributor

mikioh commented Aug 27, 2013

Comment 9:

This issue was updated by revision 519a9e8.

R=alex.brainman
CC=golang-dev
https://golang.org/cl/13184043

@rsc rsc added this to the Go1.2 milestone Apr 14, 2015
@rsc rsc removed the go1.2maybe label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
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

5 participants