TreeviewCopyright © aleen42 all right reserved, powered by aleen42
Unix Socket(Unix域套接字) Back
- Unix域Socket不是真正的網絡協議
- 既提供分佈式進程間通信, 也提供同一台機器的進程間通信
- 雙向通道
- 分類(與pipe類似)
- named
- unnamed
1. Named Unix Socket
- Unix域協議地址
- bind時綁定一個Unix Socket時, 在該路徑名創建一個文件
- 服務器可以接受多個客戶端鏈接請求
- 使用
connect()
鏈接服務器
struct socketaddr_un
{
short int sun_family; //AF_UNIX
char sun_path[104]; //file path
}
2. Unnamed Unix Socket
- socketpair通常使用於父子進程間通信
- 父進程f[0]關閉
- 子進程f[1]關閉
- 通信前不需要進行鏈接
- socket是全雙工的
method
int socketpair(int family, int type, int protocol, int fd[2])
parameters
- family: 必須是AF_UNIX
- type: SOCK_STREAM/SOCK_DGRAM
- protocol: 0
- fd: 存儲已創建的socket
return value
- 0: success
- -1: failure
As the plugin is integrated with a code management system like GitLab or GitHub, you may have to auth with your account before leaving comments around this article.
Notice: This plugin has used Cookie to store your token with an expiration.