The net package in go provides this function:
func ResolveUnixAddr(net, addr string) (*UnixAddr, error)
The string parameter net gives the network name, "unix", "unixgram" or "unixpacket".
I guess the the network name's meaning as:
unixgram: as type SOCK_DGRAM in socket() function, used by ListenPacket() in net package.
unixpacket: as type SOCK_STREAM in socket() function, used by Listen() in net package.
unix: either
Am I right?
Looking at the unixSocket function in net/unixsock_posix.go, we have:
var sotype int
switch net {
case "unix":
sotype = syscall.SOCK_STREAM
case "unixgram":
sotype = syscall.SOCK_DGRAM
case "unixpacket":
sotype = syscall.SOCK_SEQPACKET
default:
return nil, UnknownNetworkError(net)
}
So you're right about unixgram being a datagram socket, but it is unix that refers to the the stream type socket and unixpacket refers to a sequential packet socket (i.e. data is sent in packets as with datagram sockets, but they are delivered in order).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With