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: ListenIP can't use on Linux(Ubuntu) but goot at windows #7439

Closed
gopherbot opened this issue Mar 2, 2014 · 2 comments

Comments

Projects
None yet
2 participants
@gopherbot
Copy link

commented Mar 2, 2014

by jikai507:

My code blow:

package main

import (
    . "fmt"
    "net"
)

func main() {
    addr := net.IPAddr{
        IP: net.ParseIP("127.0.0.1"),
    }
    ipls, err := net.ListenIP("ip", &addr)
    if err != nil {
        Println(err.Error())
        return
    }
    defer ipls.Close()
}


What is the expected output?
It sill compile success on windows.

What do you see instead?
listen ip 127.0.0.1: protocol not supported

Which operating system are you using?
ubuntu 12.04

Which version are you using?  (run 'go version' or 'gccgo --version')
go v1.2

Please provide any additional information below.
I also try to use syscall.Socket(syscall.AF_PACKET, syscall.SOCK_RAW, syscall.IPPROTO_IP)

but when I want to send a buf to an ip address, what address struct should I use?
@mikioh

This comment has been minimized.

Copy link
Contributor

commented Mar 3, 2014

Comment 1:

The first argument of ListenIP should be "network"+":"+"protocol on top of the IPv4 or
IPv6". For example,
ListenIP("ip4:1", ...) // ICMP for IPv4
ListenIP("ip4:ospf", ...) // OSPFv2 for IPv4
ListenIP("ip6:58", ...) // ICMP for IPv6
ListenIP("ip6:gre", ...) // GRE over IPv6
> ... try to use syscall.Socket(syscall.AF_PACKET, ...
Syscall API is almost the same as C libary API, so syscall.RawSockaddrLinklayer.

Status changed to Invalid.

@gopherbot

This comment has been minimized.

Copy link
Author

commented Mar 6, 2014

Comment 2 by jikai507:

лл  ��������
2014��3��3�� ����10:27�� <go@googlecode.com>���

@gopherbot gopherbot added the invalid label Mar 6, 2014

@golang golang locked and limited conversation to collaborators Jun 25, 2016

This issue was closed.

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.