net.ListenPacket on windows vs linux

462 views
Skip to first unread message

Kevin D

unread,
Nov 18, 2013, 5:02:34 PM11/18/13
to golan...@googlegroups.com
I'm having problems getting a piece of code that works on linux to work on windows.
I'm sending some raw TCP packets and to initalize the socket, i'm doing this on linux:

package main
import (
  "net"
)
func main() {
  _, err := net.ListenPacket("ip4:tcp", "0.0.0.0")
  if err != nil {
    panic(err)
  }
}


If I run this on windows, I get "panic: listen ip4:tcp 0.0.0.0: bind: An invalid argument was supplied."
If I change the parameters of ListenPacket to net.ListenPacket("ip4:tcp", "0.0.0.0:0"), I get
"panic: listen ip4:tcp: GetAddrInfoW: No such host is known.".

I tried every possible combination of parameters for net.ListenPacket, from specifying my local ip to
specifying a port, to changing the net parameter to whatever i could think of.

Anyone has an insight?

Kevin D

unread,
Nov 18, 2013, 5:05:59 PM11/18/13
to golan...@googlegroups.com
I also tried running as admin, and tried multiple windows machines and all the same result.

Dave Cheney

unread,
Nov 18, 2013, 5:52:16 PM11/18/13
to Kevin D, golang-nuts
That case looks like it is under tested in the net package tests.
Having said that, the documentation for ListenPacket does not list
"ip4:tcp" as a permitted network.

Please consider raising an issue, golang.org/issue

On Tue, Nov 19, 2013 at 9:05 AM, Kevin D <nob...@gmail.com> wrote:
> I also tried running as admin, and tried multiple windows machines and all
> the same result.
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

brainman

unread,
Nov 18, 2013, 5:53:17 PM11/18/13
to golan...@googlegroups.com
I have reported your problem here https://code.google.com/p/go/issues/detail?id=6786.

Alex

brainman

unread,
Nov 18, 2013, 6:10:18 PM11/18/13
to golan...@googlegroups.com, Kevin D
On Tuesday, 19 November 2013 09:52:16 UTC+11, Dave Cheney wrote:

Please consider raising an issue, golang.org/issue


Tad Glines

unread,
Nov 19, 2013, 10:41:00 AM11/19/13
to brainman, golang-nuts, Kevin D
Starting with Windows XP SP2 SOCK_RAW was limited so that TCP data is disallowed. I think it still works for Windows Server versions.

-Tad


--
Reply all
Reply to author
Forward
0 new messages