套接字

sockets 清单属性声明了 sockets.udpsockets.tcpsockets.tcpServer API 可用的权限。

manifest.json 示例

{
 
"name": "My Sockets app",
 
"sockets": {
   
"udp": {
     
// Permission for chrome.sockets.udp.send:
     
// The application is allowed to send udp packets
     
// to any host:port combination.
     
"send": "*"
   
},
   
"tcp": {
     
// Permission for chrome.sockets.tcp.connect:
     
// The application is allowed to connect only to the
     
// tcp server on 127.0.0.1 port 80.
     
"connect": "127.0.0.1:80"
   
},
   
"tcpServer": {
     
// Permission for chrome.sockets.tcpServer.listen:
     
// The application is allowed to accept new client
     
// connections on the local address at port 80.
     
"listen": "127.0.0.1:80"
   
}
 
},
 
...
}

参考

  • udp(对象) - 可选

    udp 清单属性声明应用可以发出哪些 sockets.udp 操作。

    类型属性说明
    字符串或字符串数组(可选)绑定

    bind 操作的主机:端口模式。

    字符串或字符串数组(可选) send

    send 操作的主机:端口模式。

    字符串或字符串数组(可选) multicastMembership

    joinGroup 操作的主机:端口模式。

  • tcp(对象) - 可选

    tcp 清单属性声明应用可以发出哪些 sockets.tcp 操作。

    类型属性说明
    字符串或字符串数组(可选)连接

    connect 操作的 host:port 模式。

  • tcpServer(对象)- 可选

    tcpServer 清单属性声明应用可以发出哪些 sockets.tcpServer 操作。

    类型属性说明
    字符串或字符串数组(可选)listen

    listen 操作的主机:端口模式。