-
Notifications
You must be signed in to change notification settings - Fork 18k
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: error message for ListenIP is confusing #36436
Comments
@perillo Thanks for looking into this. The following works for me on Linux:
I think what may be confusing here is the error message when the protocol is omitted, which is, as you said, Lines 174 to 177 in 77c1302
The documentation points to
Does that make sense? How could we improve this? Out of curiosity, what are you using |
@toothrot, I was using the ListenIP function because I totally missed the second part of the Dial function documentation about IP networks. The documentation is correct and probably is just the error message that should be more explicit. Thanks. |
@perillo Thanks! Just to restate, it sounds like the error message for |
The answer, as far as I can tell, is that the Lines 12 to 28 in 9341fe0
On linux or similar systems, I believe it uses Lines 29 to 55 in 9341fe0
I'm not sure if I can definitively answer a question about the portability of the |
@toothrot, note that services is used for looking at the default TCP/UDP port for common services. Looking at the Line 173 in 9341fe0
In iprawsock.go, parseNetwork is called with needProto = false, and in iprawsock_posix.go it is called with needProto = true. I assume that in #7439, windows was not included in the build tags, so needProto was set to false, causing the call to the Windows API to fail with EPROTONOSUPPORT. So the documentation is probably correct, since all know systems need the protocol number/name. |
I tested on Windows 10 amd64 with the latest version of go.
|
What about I wonder if we're trying to parse |
@bradfitz: it is the same error Other protocol 0, 1 and 17 works. Also The cause seems to be a Windows restriction: |
This issue can probably be closed. Sorry for the noise. |
There is another small issue in the documentation, due to platform limitations. One entry of the bug list for the net package says: So, calling net.ListenPacket("ip4:proto", addr) will return a net.PacketConn, that is actually unusable. |
Another Issue I am facing. Client (DialIP with ip4:tcp) -> closed Server Port (retrun FIN-ACK) conn, err := net.DialIP("ip4:tcp", &localaddr, &remoteaddr) |
net.ListenIP
The documentation of
net.ListenIP
says:However using one of the documented IP network names (like "ip" or "ip4") causes the function to return an error on Linux; e.g.
unknown network ip
.According to #7439:
I confirmed that this works on Linux, but the function is clearly not documented correctly. From #7439 I assume that the format of
network
is platform dependant.net.DialIP
The documentation of the network parameter of
net.DialIP
has the same problem as innet.ListenIP
.The text was updated successfully, but these errors were encountered: