Unixgram not working ?

109 views
Skip to first unread message

Simon Lipp

unread,
Sep 15, 2011, 10:18:59 AM9/15/11
to golang-nuts
Hello,

I can’t get unixgram working ; I have the same problem that the one
described in this thread :

http://groups.google.com/group/golang-nuts/browse_thread/thread/7d387e4f38ccb500

(in short : ReadFrom returns an error, "address family not supported
by protocol")

./all.bash shows no error. I test it with socat ; to be more precise,
"socat UNIX-RECVFROM:/tmp/test-udg STDOUT" followed by "echo test |
socat STDIN UNIX-SENDTO:/tmp/test-udg" works as expected, whereas "./
test-udg" (from test-udg.go) followed by "echo test | socat STDIN UNIX-
SENDTO:/tmp/test-udg" results in the error described above.

The error is still here if I use ListenUnixgram instead of
ListenPacket (BTW, why does ListenUnixgram returns an UPDConn ?
doesn't sounds logical to me ;))

Here is test-udg.go :

package main

import (
"net"
"fmt"
"os"
)


func main() {
c, err := net.ListenPacket("unixgram", "/tmp/test-udg")
if err != nil {
panic(fmt.Sprintf("ListenPacket failed: %v\n", err))
}
for {
buf := make([]byte, 258)
length, _, err := c.ReadFrom(buf)
if err != nil {
fmt.Fprintf(os.Stderr, "ReadFrom failed: %v
\n", err)
return
}
print(string(buf[:length]))
}
}


Any help would be appreciated ;)

Kyle Lemons

unread,
Sep 15, 2011, 4:20:38 PM9/15/11
to Simon Lipp, golang-nuts
I don't understand all of the intricacies of unixgram, but when you're dialing from Go that problem seems to be avoided by specifying a local address.  I'm not sure if this is a limitation in our datagram server or not.

~K
Reply all
Reply to author
Forward
0 new messages