Hi everyone, I am sorry for my newbie question.
I want to study law-level socket programming in go using system calls (such as to implement ARP). For my first trial I have tested the code below named socket.go on Mac OS X 10.11.5 (darwin amd64), but I got the following error: # go run packet.go ./socket.go:17: cannot use sa (type unix.SockaddrInet4) as type unix.Sockaddr in argument to unix.Connect: unix.SockaddrInet4 does not implement unix.Sockaddr (unix.sockaddr method has pointer receiver) Whereas $GOPATH/src/golang.org/x/sys/unix/syscall_darwin.go seems not to implement sockaddr for SockaddrInet4, $GOPATH/src/golang.org/x/sys/unix/syscall_linux.go implements sockaddr for SockaddrInet4. So I tested the same code on Linux VM (Arch Linux), but I got the same error. My questions: - Why my code causes the error in Linux? - Is it impossible to use unix.SockaddrInet4 as type unix.Sockaddr in darwin? Thank you. ---- packet.go ---- package main import ( "fmt" "os" "golang.org/x/sys/unix" ) func main() { fd, err := unix.Socket(unix.AF_INET, unix.SOCK_RAW, 0) if err != nil { fmt.Println("Can't open the socket:", err) os.Exit(1) } sa := unix.SockaddrInet4{Port: 0, Addr: [4]byte{127, 0, 0, 1}} err = unix.Connect(fd, sa) if err != nil { fmt.Println("Can't connect:", err) os.Exit(1) } } -- 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+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.