Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
net: Dial("ip", ...) fails on Windows with "ConnectEx ip4: An invalid argument was specified" #6122
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)
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.
This issue was closed.