Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sockets go语言中的Unix域套接字名称_Sockets_Unix_Go - Fatal编程技术网

Sockets go语言中的Unix域套接字名称

Sockets go语言中的Unix域套接字名称,sockets,unix,go,Sockets,Unix,Go,go中的net软件包提供以下功能: func ResolveUnixAddr(net, addr string) (*UnixAddr, error) 字符串参数net给出网络名称“unix”、“unixgram”或“unixpacket” 我猜网络名称的含义如下: unixgram:在socket()函数中作为类型SOCK_DGRAM,由net包中的ListenPacket()使用 unixpacket:在socket()函数中作为类型SOCK_STREAM,由net包中的Listen()

go中的net软件包提供以下功能:

func ResolveUnixAddr(net, addr string) (*UnixAddr, error)
字符串参数
net
给出网络名称“unix”、“unixgram”或“unixpacket”

我猜网络名称的含义如下:

  • unixgram:在socket()函数中作为类型SOCK_DGRAM,由net包中的ListenPacket()使用

  • unixpacket:在socket()函数中作为类型SOCK_STREAM,由net包中的Listen()使用

  • unix:不是


我说得对吗?

查看中的
unixSocket
函数,我们有:

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)
}

因此,关于
unixgram
是一个数据报套接字,您是对的,但是
unix
指的是流类型套接字,而
unixpacket
指的是一个顺序数据包套接字(即数据与数据报套接字一样以数据包的形式发送,但它们是按顺序传递的).

我为SOCK_SEQPACKET查找。请考虑类似于SEQPACKET的流,但套接字上的每个
recv
操作将对应于另一端的
发送。也就是说,当另一方读取时,写入边界将保持不变。